TEHRAN
IN ENGLISH · OPENAI FROM IRAN

ChatGPT API from Iran

You can reach OpenAI's models from an Iranian network — just not from an OpenAI account, because OpenAI neither sells service nor accepts payment in Iran. The route that works is a gateway that holds the provider relationship for you. 1xAi is one: it runs inside Iran, speaks the OpenAI wire format at https://1xai.ir/v1, relays your request to the official API, and bills you in Toman.

[01]THE SHORT ANSWER

What works, and what doesn't

Direct OpenAI account
Not available. OpenAI does not offer service in Iran, and no Iranian payment instrument can fund an account.
VPN + foreign card
Moves your IP, nothing else. You still need a payment method OpenAI accepts, and an account opened this way sits outside their terms; the failure mode is a closed account with your balance inside it.
Gateway (this site)
Works from an Iranian IP with no VPN. You keep OpenAI-shaped code and swap the base URL; the gateway holds the upstream relationship and settles your usage in Toman.
What a gateway can't fix
Provider policy. Responses come from the real models, so OpenAI's content and usage policies apply exactly as they would upstream. A gateway is a route, not an exemption.
[02]THE THREE WALLS

Why the direct route fails

People usually discover this in the wrong order. The network block is the loud one, so a VPN looks like the fix, and for about ten minutes it is. The other two walls are the ones that actually stop projects.

  1. [01]

    Network. Requests from Iranian IP ranges do not reach the provider APIs. This is the wall a VPN or a foreign VPS removes, and the only one.

  2. [02]

    Payment.API access is prepaid with a card the provider accepts. Iranian cards do not clear internationally, and the usual workarounds (a friend abroad, a resold virtual card) put someone else's name on your production dependency.

  3. [03]

    Standing.An account opened against the provider's regional terms can be closed without notice, and prepaid balance is not portable. For a hobby script that is an annoyance; for anything with users on it, it is an outage you cannot schedule.

A gateway addresses all three at once, and is honest about the fourth thing it does not address: the provider's own policies still govern the model's behaviour.

[03]THE CHANGE

One line of code

1xAi implements the OpenAI HTTP API, so the official SDKs and everything built on them work unmodified. Point the client at https://1xai.ir/v1, authenticate with a 1xai- key instead of an sk- key, and the rest of your code, from streaming and tool calls to JSON mode and token accounting, behaves the way it does upstream.

python — official openai SDK, unmodifiedpython
# pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://1xai.ir/v1",   # the only change
    api_key="1xai-...",              # your 1xAi key, not an sk- key
)

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Write a haiku about Tehran traffic."}],
)
print(resp.choices[0].message.content)
print(resp.usage)  # prompt/completion tokens, same shape as upstream

Or with no SDK at all. Streaming is Server-Sent Events, as upstream; 1xAi adds stream_options.include_usage for you so the final chunk carries token counts.

curl — streaming chat completionbash
curl https://1xai.ir/v1/chat/completions \
  -H "Authorization: Bearer 1xai-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "ping"}],
    "stream": true
  }'

The same key and the same base URL also reach Anthropic, Google and DeepSeek models, over 38 in total, by changing the model field alone. Full route reference on the endpoint page, live per-model prices on the models page.

[04]COST

What it actually costs

API usage is pay-as-you-go from a wallet balance: the provider's own USD list price for the model you called, plus a flat 20% markup, converted to Toman. That is the entire pricing rule: no seat licences, no monthly minimum, no separate rate per endpoint. Top-ups go through Zarinpal with a minimum of 100,000 Toman.

Two things are free to start with. A free account carries a chat allowance of 100,000 Toman every 30 days (40,000-Toman weekly cap) on gpt-4o-mini, claude-haiku-4-5 and gemini-2.5-flash, and every new account gets one server-drawn spin of a gift wheel worth 100,000 to 1,000,000 Toman in wallet credit — that credit never expires and can be spent on API calls. Pricing in detail.

[05]THE FINE PRINT

What you are actually signing up for

You are adding a hop. Your prompt goes to a server in Iran, which forwards it to the provider and forwards the answer back, so treat it the way you would treat any third-party API middleman, and keep material you are not willing to route through an intermediary out of it. In exchange you get an endpoint that resolves from an Iranian network, a wallet you can fund with a local card, and one integration instead of four.

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.

FAQ · IN ENGLISH

Can I call the OpenAI API from Iran?

Not directly with an OpenAI account — OpenAI does not offer service or accept payment in Iran. What does work is a gateway that holds the provider relationship on your behalf. 1xAi is a gateway operated inside Iran: you send OpenAI-shaped requests to base_url https://1xai.ir/v1 with a 1xAi key, and it relays them to the official API and returns the real model's response.

Do I need a VPN to use 1xAi?

No. The endpoint is reachable from Iranian networks, which is the point of running the gateway inside the country. A VPN would only move your IP address anyway; it does not solve payment, and it does not give you an account standing you did not have.

Do I have to change my code?

One line. 1xAi speaks the OpenAI wire format, so any OpenAI-compatible client (the official Python and Node SDKs, LangChain, LlamaIndex, Cursor, or your own HTTP calls) works once you set base_url to https://1xai.ir/v1 and use a 1xai- key. Streaming, tool calling and JSON mode behave as they do upstream.

How do I pay without an international card?

In Iranian Toman through Zarinpal, a local payment gateway, with a minimum top-up of 100,000 Toman. API usage is pay-as-you-go from that wallet balance: each model is billed at the provider's own USD list price plus a flat 20% markup, converted to Toman. There is no subscription requirement for API access.

Is this an official OpenAI service?

No. 1xAi is an independent gateway and is not affiliated with or endorsed by OpenAI. Responses come from the official models, so OpenAI's own usage policies apply to what the models will and will not do, and OpenAI can change model availability at any time.

Is there a way to test it before paying?

Yes. A free account includes a chat allowance of 100,000 Toman every 30 days, with a 40,000-Toman weekly cap, on gpt-4o-mini, claude-haiku-4-5 and gemini-2.5-flash. Every new account also gets one server-drawn spin of a gift wheel worth 100,000 to 1,000,000 Toman in wallet credit, which never expires and can be spent on API usage.

MORE IN ENGLISH
  • Overview

    What 1xAi is, who it is for, and what it costs — the English entry point.

  • Claude API from Iran

    Anthropic's Messages API from Iran, including the native passthrough route.

  • 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.