IranRouter
Docs contents

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.

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:

SDKBase URL
OpenAIhttps://iranrouter.com/openai
Anthropichttps://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

TopicOpenAIIranRouter
Model namegpt-4o-miniboth gpt-4o-mini and the full openai/gpt-4o-mini — see models
CurrencyUSDRial, at the daily FX rate
PaymentCredit cardPrepaid wallet + official invoice
Other vendors' modelsNot availableSame key, same URL — Claude, Gemini and the rest
Other endpointsembeddings, images, audio, responsesNot 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