Docs
IranRouter docs
Everything about calling IranRouter — from your first request to production agents.
IranRouter speaks the OpenAI API. Any SDK, library or tool that works with OpenAI connects here by changing two values — the base URL and the key. Nothing in your code needs rewriting.
client = OpenAI(
api_key="ir-...", # ← your IranRouter key
base_url="https://iranrouter.com/v1", # ← instead of api.openai.com
)Billing is in Rial, an official invoice is issued, and no foreign card is required. You are charged for tokens actually consumed, not a monthly subscription.
Where to start
What is supported
| Capability | Status |
|---|---|
POST /v1/chat/completions | Fully supported, streaming and non-streaming |
POST /v1/messages | Anthropic-format compatible |
| Tools / function calling | On both surfaces |
| Vision / image input | On models that support it |
| Prompt caching | Supported and priced separately |
GET /v1/models · /v1/key · /v1/credits | Supported |
POST /v1/embeddings | Supported, non-streaming |
POST /v1/messages/count_tokens | Supported — an estimate, free |
POST /v1/rerank · /v1/moderations · /v1/completions | Supported, non-streaming |
POST /v1/images/generations | Supported — billed per image, max 10 per request |
POST /v1/audio/speech | Supported — the response is audio; cost in the x-cost-rial header |
POST /v1/audio/transcriptions · /translations | Supported — multipart, the file is forwarded untouched |
POST /genai/v1beta/models/… | Google GenAI SDK compatible |
| A base URL per SDK | The same surface under four prefixes: /v1 (default), /openai, /anthropic and /genai |
Leave your SDK alone and change only its base URL: /anthropic for the Anthropic SDK (it appends /v1/messages itself), /genai for the Google GenAI SDK, and /openai or /v1 for the OpenAI SDK. All four are one engine; the prefix exists so migrating is one line of config, not a code change.
What we do not have yet
Stated plainly so nobody buys on a wrong assumption:
/v1/responses,/v1/batches— not offered yet./v1/batches— not implemented.