The OpenAI-compatible endpoint
The base URL is https://1xai.ir/v1 and the auth header is Authorization: Bearer 1xai-… — set those two in any OpenAI client and every model on the gateway, from four providers, is addressable by the model field alone. Two native passthrough routes sit next to it for the provider features the OpenAI schema cannot carry.
Everything you need on one screen
- Base URL
https://1xai.ir/v1- Auth
Authorization: Bearer 1xai-…on every request. Keys are minted in the dashboard; a key can also read its own account's usage.- Routes
/v1/chat/completions,/v1/embeddings,/v1/images/generations,/v1/audio/speech,/v1/audio/transcriptions,/v1/moderations,/v1/files,/v1/models.- Native routes
/anthropic/v1/*(Messages API,x-api-key+anthropic-version) and/gemini/v1beta/*(generateContent,x-goog-api-keyor?key=).- Streaming
"stream": truereturns Server-Sent Events;stream_options.include_usageis added for you, so the terminal chunk carries token counts.- Models
- Over 38, across OpenAI, Anthropic, Google and DeepSeek. The live list with Toman prices is on the models page.
Switching provider is a string change
The reason to use the compatibility route rather than four SDKs: the request body does not change when the provider does. The same call reaches a Google model here, and an Anthropic or OpenAI one by editing a single field — which makes model A/B tests, per-tenant model choice and graceful fallback ordinary code rather than an integration project.
// npm i openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://1xai.ir/v1",
apiKey: process.env.ONEXAI_API_KEY, // "1xai-..."
});
const stream = await client.chat.completions.create({
model: "gemini-2.5-flash", // or gpt-4o-mini, claude-haiku-4-5, deepseek-chat
messages: [{ role: "user", content: "List three uses for an OCR pipeline." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}The rest of the surface
Chat is the busiest route but not the only one. Embeddings, image generation, speech synthesis and transcription all sit under the same base URL with the same key and the same wallet, so a pipeline that mixes them needs one credential.
# every model your key can address, OpenAI /v1/models shape
curl https://1xai.ir/v1/models \
-H "Authorization: Bearer 1xai-..."
# embeddings, same base URL, same key
curl https://1xai.ir/v1/embeddings \
-H "Authorization: Bearer 1xai-..." \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "سلام دنیا"}'Your own usage, over the API
Cost visibility is part of the API rather than a dashboard-only feature. The same 1xai-key reads the account's call log and daily roll-ups, which is what you want when you are attributing spend to a tenant or wiring a budget alarm.
# what you spent, per call — no dashboard scraping, no second token curl "https://1xai.ir/v1/usage?limit=50&status=success&model=gpt-4o-mini" \ -H "Authorization: Bearer 1xai-..." # daily roll-up for the last 30 days curl "https://1xai.ir/v1/usage/summary?days=30" \ -H "Authorization: Bearer 1xai-..."
What the compatibility layer costs you
A single wire format is a simplification, and simplifications lose things. Anthropic's cache_control, extended thinking, citations and server-side tools have no field in the OpenAI schema; neither do Google's cachedContents or grounding. On /v1 those parameters are dropped rather than translated, silently, because there is nothing to translate them into. If your prompt repeats a large fixed block on every call, that is exactly the feature you want, and the native route is where it lives: see the Claude page for a working example.
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google or DeepSeek. Requests are relayed to those providers' official APIs, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.
What is the base URL?
https://1xai.ir/v1 — that is the OpenAI-compatible base URL. Set it as base_url in any OpenAI client and authenticate with Authorization: Bearer 1xai-YOURKEY. Two native passthrough routes sit alongside it: https://1xai.ir/anthropic for the Anthropic Messages API and https://1xai.ir/gemini/v1beta for Google's Generative Language API.
Which OpenAI endpoints are supported?
Chat completions at /v1/chat/completions, plus embeddings, images/generations, audio/speech, audio/transcriptions, moderations, files and models, all under the same base URL and the same key. Streaming is Server-Sent Events, and 1xAi sets stream_options.include_usage so the final chunk carries token counts.
Can one key reach models from different providers?
Yes, and that is the point of the compatibility route. Over 38 models from OpenAI, Anthropic (Claude), Google (Gemini) and DeepSeek are addressed by the model field alone: gpt-4o-mini, claude-haiku-4-5 and gemini-2.5-flash are all valid values on the same request shape, billed to the same wallet.
Can I read my own usage programmatically?
Yes, with the same key and no extra credential. GET /v1/usage returns logged calls with filters for limit, from, to, model, provider and status; GET /v1/usage/summary?days=N returns a daily roll-up; GET /v1/keys lists your keys. Each key can read the reports of the account that owns it.
Do I lose provider-specific features by using the OpenAI shape?
Some, yes, and it is worth knowing before you build. The OpenAI compatibility schema has nowhere to carry Anthropic prompt caching (cache_control), extended thinking, citations or server-side tools, nor Google's cachedContents and grounding, so those are dropped on /v1. Use the native passthrough route for the provider when you need them.
- Overview
What 1xAi is, who it is for, and what it costs — the English entry point.
- ChatGPT API from Iran
Whether the OpenAI API can be called from an Iranian network, and how.
- Claude API from Iran
Anthropic's Messages API from Iran, including the native passthrough route.
- Pricing
How billing works: list price plus a flat 20% markup, paid in Toman.
- Service status
Live per-provider reachability measured from inside Iran, plus the raw dataset.