Integrations
MirAPI speaks the three mainstream protocols — OpenAI, Anthropic, and Gemini — so almost any tool that can call a large language model can be pointed at MirAPI. In most tools you change exactly three things: the base URL, the API key, and the model name.
What you need
Section titled “What you need”| Element | Value |
|---|---|
| API key | MIRAPI_API_KEY, created in https://console.mirapi.ai → API Keys |
| Model name | deepseek-chat — the exact id returned by GET /v1/models |
| Base URL | depends on the protocol, see below |
A minimal OpenAI-compatible request confirms the three are wired up correctly:
curl https://api.mirapi.ai/v1/chat/completions \ -H "Authorization: Bearer $MIRAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-chat", "messages": [{"role": "user", "content": "Hello!"}] }'Choosing the base URL
Section titled “Choosing the base URL”| Tool protocol | Base URL | Typical tools |
|---|---|---|
| OpenAI-compatible | https://api.mirapi.ai/v1 |
Cursor, Cline, Roo Code, Chatbox, LangChain, n8n, most SDKs |
| Anthropic | https://api.mirapi.ai (bare, no /v1) |
Claude Code, Anthropic SDK |
| Gemini | https://api.mirapi.ai or https://api.mirapi.ai/v1beta |
Gemini CLI, Google GenAI SDK |
One rule covers most tools: if the tool appends /chat/completions (or any other path) to the base URL itself, enter https://api.mirapi.ai/v1. If the tool expects the raw API origin — as Anthropic and Gemini clients do — enter https://api.mirapi.ai as-is.
Authentication
Section titled “Authentication”| Protocol | Accepted header(s) |
|---|---|
| OpenAI-compatible | Authorization: Bearer <key> (a bare key also works) |
| Anthropic | x-api-key or Authorization: Bearer |
| Gemini | x-goog-api-key or ?key= |
The same MIRAPI_API_KEY works across all three protocols, so you need only one key. The Authorization scheme is case-insensitive, and the OpenAI-Organization header is accepted but ignored — there is no per-organization isolation.
Each key can carry four constraints: a model whitelist (models outside it return 403), a validity period, a quota cap, and an IP allowlist. A 401 means the key is missing, invalid, or unknown; a 403 means the key is valid but the request was rejected.
Tools covered here
Section titled “Tools covered here”| Tool | Protocol | Page |
|---|---|---|
| Claude Code | Anthropic | Claude Code |
| Codex CLI | OpenAI (Responses) | Codex CLI |
| Cursor | OpenAI | Cursor |
| Cline / Roo Code | OpenAI | Cline · Roo Code |
| Gemini CLI | Gemini | Gemini CLI |
| OpenCode | OpenAI | OpenCode |
| Continue | OpenAI | Continue |
| Chatbox / Cherry Studio / LobeChat / NextChat | OpenAI | Chatbox · Cherry Studio · LobeChat · NextChat |
| Anthropic SDK | Anthropic | Anthropic SDK |
| LangChain / LlamaIndex | OpenAI | LangChain · LlamaIndex |
| Vercel AI SDK | OpenAI | Vercel AI SDK |
| Dify / n8n | OpenAI | Dify · n8n |
| Immersive Translate | OpenAI | Immersive Translate |
Every tool page follows the same shape: the essentials, configuration steps, a send-a-message check, tool-specific pitfalls, and related links.
MCP servers
Section titled “MCP servers”MCP (Model Context Protocol) servers run unchanged with MirAPI: they are tools your agent invokes locally or remotely, and only the model API goes through the gateway. Configure your agent (Claude Code, Cursor, Cline, …) with the MirAPI base URL and key exactly as described on its page, and its MCP tools keep working — nothing about the MCP servers themselves needs to change.
Billing
Section titled “Billing”All integrations share one prepaid USD balance. There is no subscription, monthly fee, or minimum spend, and the balance never expires. Text and multimodal chats bill per token, images per image, and video per second of output. When the balance runs out, requests return 403; top up and the same key works again immediately.
Troubleshooting
Section titled “Troubleshooting”- 401 — the key is missing, invalid, or unknown. Regenerate it in the console and check the environment variable.
- 403 — the key is valid but the request was rejected. Most often the model is not on the key’s whitelist or the balance is exhausted. Top up or check the key’s constraints, then retry.
- 413 — the request is too large. Reduce the payload size.
- 429 — rate limited. Back off with jittered exponential delay (1s → 2s → 4s, cap ~30s) and retry; the gateway does not retry on your behalf, and no
Retry-Afterheader is sent. - 500 — server or upstream error. Safe to retry idempotent requests.
- Model not found — the model name must match
GET /v1/modelsexactly. Use the exact catalogue name, without thevendor/prefix.
Every error message ends with a request ID — include it in any support ticket.