An AI API that works from Iran, one line to switch
IranRouter is an OpenAI SDK compatible API that works from inside Iran and reaches many makers' models with one key. Keep your code and change only the base URL and the key.
Where connecting from Iran breaks
Foreign services refuse requests from Iranian IPs, and an Iranian bank card cannot pay them. An ir- key works from inside Iran and is billed in Rial from your wallet.
What changes in your code
Two values: base_url and api_key. You pick a model by its id, and the same code works for the next one. Each model's exact id is on its own page.
SDKs and routes
- The OpenAI SDK and compatible libraries: /v1/chat/completions and /v1/responses.
- The Anthropic SDK with the /anthropic base URL.
- The Google GenAI SDK with the /genai base URL.
- Streaming, tools, image input on models that support it, and prompt caching.
Keeping your key safe
An ir- key can spend from your wallet, so keep it server side, never in browser or mobile code. Give each app its own key, so a leak costs you only that one. The dashboard shows each key's usage: model, token counts, time and cost.
How the connection looks
from openai import OpenAI client = OpenAI( api_key="ir-...", base_url="https://iranrouter.com/v1", )
Frequently asked questions
Do I need a VPN to call the API?
No. The API address is reachable from inside Iran.
Do I have to rewrite my code?
No. With the OpenAI SDK only base_url and the key change. The Anthropic and Google SDKs have their own base URLs.
Is streaming supported?
Yes, token by token over SSE.