Docs
Migrating from OpenAI
The two values that change — and an exact list of where we differ from OpenAI.
If you call OpenAI directly today, the migration is two lines. This page says exactly what is identical and where we differ, so nothing surprises you.
What changes
- base_url="https://api.openai.com/v1"
+ base_url="https://iranrouter.com/v1"
- api_key="sk-..."
+ api_key="ir-..."That is all. The rest of your code is untouched.
If your SDK is not OpenAI's
You still do not have to change code. The same surface is served under a prefix per SDK, so migrating is still one config line:
| SDK | Base URL |
|---|---|
| OpenAI | https://iranrouter.com/openai |
| Anthropic | https://iranrouter.com/anthropic |
| Google (google-genai) | https://iranrouter.com/genai |
All three are one engine and take the same ir- key; the prefix simply lets each SDK build the paths it already knows. Details in Messages and Gemini-native ingress.
What is identical
- The chat-completions request and response shape, streaming and not.
- Tools, structured output, images, and the usual sampling parameters.
- The error envelope (error.type, error.message, error.code).
- OpenAI-style rate-limit headers.
Real differences
| Topic | OpenAI | IranRouter |
|---|---|---|
| Model name | gpt-4o-mini | both gpt-4o-mini and the full openai/gpt-4o-mini — see models |
| Currency | USD | Rial, at the daily FX rate |
| Payment | Credit card | Prepaid wallet + official invoice |
| Other vendors' models | Not available | Same key, same URL — Claude, Gemini and the rest |
| Other endpoints | embeddings, images, audio, responses | Not offered yet |
Environment variables
Most tools read these two standard variables, so often you touch no code at all:
export OPENAI_BASE_URL="https://iranrouter.com/v1"
export OPENAI_API_KEY="ir-..."OPENAI_API_BASE instead of OPENAI_BASE_URL. If your tool will not connect, set both.The origin without /v1 is occasionally needed too: https://iranrouter.com