# Immersive Translate

> Route Immersive Translate translation requests through MirAPI as a custom OpenAI-compatible service with a cheap model and low concurrency.

Immersive Translate is a bilingual-translation extension whose Translate mode can call any OpenAI-compatible endpoint. MirAPI implements the OpenAI Chat Completions API (`POST /v1/chat/completions`), so you can point Immersive Translate at MirAPI with a cheap model such as `deepseek-chat`.

## What you need

| Element | Value |
|---|---|
| API URL | `https://api.mirapi.ai/v1/chat/completions` (the full endpoint) |
| API key | Your MirAPI key (`sk-...`) |
| Model | `deepseek-chat`, or any model name from `GET /v1/models` |

## Configure

1. Create an API key in https://console.mirapi.ai → **API Keys** and copy it.
2. Open **Settings → Translation Services → OpenAI** (or **Add a translation service → OpenAI**).
3. Expand **More settings** and enter the custom API URL:

```text
API URL: https://api.mirapi.ai/v1/chat/completions
API key: sk-...
Model: deepseek-chat
```

4. In the provider's advanced options, **lower the request frequency** (requests per second). Page translation sends many parallel requests, and a low limit keeps you under your key's rate limit.

:::note
Model names are verbatim. Use the exact `id`/`name` from `GET /v1/models` — the `vendor/` prefix is for console browsing only and is not part of the API request.
:::

## Verify with a message

Open any web page and enable translation. The page should render in the target language within a few seconds. The first request draws a small amount from your prepaid balance; confirm it later in the console billing log or with `GET /api/usage/token`.

## Billing

- Translation requests are billed per token (input / output / cache read, per 1M tokens USD). Reasoning and thinking tokens count as **output**.
- Immersive Translate draws from a prepaid balance: no subscription, no minimum, and the balance never expires.
- When the balance runs out, requests fail with **403**; topping up restores the same key immediately.
- Reconcile usage in the console billing log, `GET /api/usage/token` (account-level totals), or `GET /api/log/token` (per-request detail).

## Troubleshooting

- **Enter the full endpoint URL** — Immersive Translate calls the URL you enter as-is, so it must be `https://api.mirapi.ai/v1/chat/completions`; a bare `https://api.mirapi.ai/v1` returns 404.
- **Lower the concurrency limit** — translation fires many parallel requests. When you exceed the key's rate limit MirAPI answers **429** with no `Retry-After` header; retry with jittered exponential backoff (1s → 2s → 4s, capped around 30s). The gateway does not retry for you.
- **401** means the key is missing, invalid, or unknown. Check the API key field.
- **403** means the key is valid but the request was refused: balance exhausted, model not whitelisted, quota exceeded, or IP not allowed. Fix the cause and retry.
- Every error message ends with a request ID — include it when you open a support ticket.

## Related links

- [Quickstart](/docs/quickstart)
- [Models & pricing](/docs/models)
- [Billing & top-ups](/docs/billing)
- [OpenAI compatibility](/docs/openai-compat)
- [Authentication](/docs/api-reference/authentication)
- [Errors](/docs/api-reference/errors)