Claude API from Iran
Claude is reachable from an Iranian network through a gateway, not through an Anthropic account — Anthropic sells neither service nor billing into Iran. 1xAi relays to Anthropic's official API and gives you two doors: the OpenAI-shaped one at https://1xai.ir/v1, and a native Messages API passthrough at https://1xai.ir/anthropic for the Anthropic features the compatibility layer throws away.
Pick the route by what you need
- /v1/chat/completions
- OpenAI wire format. One client and one body shape for OpenAI, Anthropic, Google and DeepSeek, so swapping provider is a change to the model string. Best when you want to A/B models or keep an existing OpenAI codebase.
- /anthropic/v1/messages
- The official Messages API, passed through untouched. Use it when you need cache_control, extended thinking, citations or server-side tools, all four of which the OpenAI compatibility layer silently strips.
- Auth
- Your
1xai-key on both routes.Authorization: Beareron/v1;x-api-keyplusanthropic-versionon/anthropic, exactly as Anthropic requires. No Anthropic account of your own. - Billing
- Identical on both: provider list price plus a flat 20% markup, deducted from your Toman wallet. Token usage, including cache-read and cache-creation counts, comes from the provider's own response.
Claude through the OpenAI SDK
Any model name beginning with claude- routes to Anthropic. Nothing else about the request changes, which is why this route is the cheap way to put Claude behind an interface that already speaks OpenAI.
from openai import OpenAI # yes, the OpenAI SDK
client = OpenAI(base_url="https://1xai.ir/v1", api_key="1xai-...")
resp = client.chat.completions.create(
model="claude-haiku-4-5", # any claude-* name routes to Anthropic
messages=[{"role": "user", "content": "Summarise this changelog."}],
)
print(resp.choices[0].message.content)The Claude models exposed here include claude-opus-4-8, claude-sonnet-5 and claude-haiku-4-5; the live catalogue with Toman prices is on the models page. claude-haiku-4-5 is also one of the three models covered by the free chat plan.
When the compatibility layer isn't enough
The OpenAI schema has no field for a cache breakpoint, a thinking budget or a citation block, so a compatibility layer has nowhere to put them: they are dropped before the request leaves. If your prompt carries a large fixed system block, that silence is expensive. The native route forwards the Anthropic body verbatim.
# pip install anthropic
from anthropic import Anthropic
client = Anthropic(
base_url="https://1xai.ir/anthropic", # native passthrough
api_key="1xai-...", # sent as x-api-key
)
resp = client.messages.create(
model="claude-sonnet-5",
max_tokens=2048,
thinking={"type": "enabled", "budget_tokens": 1024},
system=[{
"type": "text",
"text": "Long domain handbook repeated on every call ...",
"cache_control": {"type": "ephemeral"}, # dropped by the /v1 route
}],
messages=[{"role": "user", "content": "Answer using the handbook only."}],
)
print(resp.content[-1].text)
print(resp.usage.cache_read_input_tokens)The same thing without an SDK. Note the two required headers:
curl https://1xai.ir/anthropic/v1/messages \
-H "x-api-key: 1xai-..." \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-haiku-4-5",
"max_tokens": 512,
"messages": [{"role": "user", "content": "ping"}]
}'Google's native surface is available the same way at https://1xai.ir/gemini/v1beta for cachedContents and grounding. Both are documented in full, in Persian, in the API docs.
What you pay and how you pay it
API calls are pay-as-you-go from a wallet balance: Anthropic's own USD list price for the model, plus a flat 20% markup, converted to Toman. Wallet top-ups run through Zarinpal with a 100,000-Toman minimum, so no international card is involved anywhere in the flow. A new account also receives one server-drawn gift-wheel spin worth 100,000 to 1,000,000 Toman in credit that never expires and can be spent on API usage, which is enough to run real requests before deciding anything. Full pricing.
What a gateway does not change
Your requests pass through an intermediary on their way to Anthropic, which is a real trade-off and should be weighed like any third-party API hop. Model behaviour is not ours to alter: refusals, safety policy and availability are Anthropic's, unchanged by the route you took to reach them.
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.
Can I use Claude from Iran?
Not with an Anthropic account — Anthropic does not offer service or accept payment in Iran. Through 1xAi you can: it is an independent gateway operated inside Iran that relays requests to Anthropic's official API. You can call Claude either through the OpenAI-shaped route at https://1xai.ir/v1 by setting the model field to a claude- name, or through the native Anthropic Messages API at https://1xai.ir/anthropic.
Which route should I use, /v1 or /anthropic?
Use https://1xai.ir/v1 if you want one client and one body shape across OpenAI, Anthropic, Google and DeepSeek models — switching provider becomes a change to the model string. Use https://1xai.ir/anthropic/v1/messages if you need Anthropic-specific features, because the OpenAI compatibility layer drops them: prompt caching via cache_control, extended thinking, citations and server-side tools only exist on the native route.
Does the official Anthropic SDK work?
Yes. Construct the client with base_url https://1xai.ir/anthropic and pass your 1xai- key as api_key; the SDK sends it as the x-api-key header, which the gateway expects, along with the required anthropic-version header. Request and response bodies are the official Messages API shape, so nothing else in your code changes.
Do I need an Anthropic account or key?
No. You authenticate with a 1xAi key and the gateway holds the upstream relationship. Usage is deducted from your Toman wallet at the provider's own USD list price plus a flat 20% markup.
Is prompt caching billed differently?
Token accounting is passed through from Anthropic's response, so cache-read and cache-creation tokens appear in the usage block exactly as upstream reports them, and the same list-price-plus-20% rule is applied to what the provider charged. Nothing about caching is re-implemented at the gateway.
Is 1xAi affiliated with Anthropic?
No. 1xAi is an independent gateway, not affiliated with or endorsed by Anthropic, and not a reseller. Responses come from the official Claude models, so Anthropic's usage policies apply to what the models will and will not do.
- 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.
- OpenAI-compatible endpoint
The base URL, the auth header, every supported route, streaming and errors.
- 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.