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
diff
- 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.
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:
bash
export OPENAI_BASE_URL="https://iranrouter.com/v1"
export OPENAI_API_KEY="ir-..."Some older libraries look for
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