API quickstart: a first request in a few minutes
Create an account, issue a 1xai-* key, point an OpenAI SDK at https://1xai.ir/v1, and send a request. The same key and base URL reach the models of 10 vendors, and the cost is taken in Toman from a wallet. A new account spins the gift wheel once and can try the API before paying anything.
Last updated:
The steps
- Create an account. Register (the app is in Persian) with an email or a mobile number and confirm it.
- Complete the identity profile. At /onboarding, enter your full name, national id and mobile number. Until the profile is complete the dashboard issues no key and takes no payment.
- Spin the gift wheel. From 100,000 Toman to 1,000,000 Toman of gift credit for the fast, inexpensive models, plus 30,000 Toman for any model; both are valid for 14 days and can be spent on API calls.
- Create a key. On the API keys page, issue a key and copy it at once; the full key is shown only once (API keys and security).
- Send a request. Any of the three samples below. To change vendor, change only the
modelfield:gpt-5.5,claude-sonnet-5orgemini-3.5-flash. - Read the usage. That call, with its Toman cost, tokens and time, is in the dashboard and in
GET /v1/usage(account API).
The first request
curl https://1xai.ir/v1/chat/completions \
-H "Authorization: Bearer 1xai-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [{"role": "user", "content": "Hello"}]
}'from openai import OpenAI
client = OpenAI(
base_url="https://1xai.ir/v1",
api_key="1xai-...",
)
resp = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://1xai.ir/v1",
apiKey: "1xai-...",
});
const resp = await client.chat.completions.create({
model: "gemini-3.5-flash",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);The answer has the shape of an OpenAI response. The X-RateLimit-* headers say how much of the key's 1,000 requests a minute is left (rate limits).
Base URLs
| For | Base URL |
|---|---|
| OpenAI SDKs and OpenAI-compatible tools | Base URL:https://1xai.ir/v1 |
| The official Anthropic SDK and Claude Code | Base URL:https://1xai.ir/anthropic |
| The official Google GenAI SDK | Base URL:https://1xai.ir/gemini |
1xAi's main servers are outside Iran. The api.1xai.ir hostname passes through a server of ours in Iran that does not open the encrypted connection; both hostnames reach the same service and are reachable from Iran without a VPN. The same paths and the same keys work on https://api.1xai.ir.
Next steps
- Authentication: the three headers that carry a key.
- Models: which model on which route.
- OpenAI-compatible endpoints: chat, Responses, embeddings, images, audio and video.
- Billing and errors.
- Tool guides: Cursor, Claude Code, n8n and others.
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, 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.