# Cline

> Point Cline's OpenAI Compatible provider at MirAPI and run its coding agent on your key: base URL, model ID, and context window.

Cline is a VS Code extension that runs an autonomous coding agent. It supports custom OpenAI-compatible providers, so you can route its requests through MirAPI on your own key.

## What you need

| Element | Value |
|---|---|
| API provider | `OpenAI Compatible` |
| Base URL | `https://api.mirapi.ai/v1` |
| API key | Your MirAPI key (`sk-...`) |
| Model ID | `deepseek-chat` |
| Context window | The model's catalogue value |

Create the key in the console (`https://console.mirapi.ai`) and check the model's context length on the [Models & pricing](/docs/models) page.

## Configure

1. Open **Cline → Settings → API Provider**.
2. Select **OpenAI Compatible**.
3. Fill in:

```text
Base URL: https://api.mirapi.ai/v1
API Key: sk-...
Model ID: deepseek-chat
```

4. Set the **context window** from the catalogue value for `deepseek-chat`. Cline uses this number to plan truncation, so an overstated value makes it overfill the request.
5. Save. Cline may offer a small test request — allow it.

## Verify with a message

Create a Cline task and send:

```text
Reply with exactly: connected to MirAPI
```

The assistant's reply should contain `connected to MirAPI`. If it does not, see Errors and troubleshooting below.

You can also confirm the model is listed before starting:

```bash
curl https://api.mirapi.ai/v1/models -H "Authorization: Bearer sk-..."
```

Look for `deepseek-chat` among the returned `id` values.

## Protocol variants

MirAPI serves three API dialects under one key. The **OpenAI Compatible** provider above is the recommended path; if you use Cline's Anthropic or Gemini provider instead, point it at the matching surface:

| Protocol | Base URL | Auth |
|---|---|---|
| OpenAI-compatible | `https://api.mirapi.ai/v1` | `Authorization: Bearer sk-...` |
| Anthropic | `https://api.mirapi.ai` | `x-api-key` or `Authorization: Bearer` |
| Gemini | `https://api.mirapi.ai` or `https://api.mirapi.ai/v1beta` | `x-goog-api-key` or `?key=` |

Whichever protocol you pick, copy the **model ID verbatim** from `GET /v1/models` — requests use the exact `id`, not the display name.

## Errors and troubleshooting

| Symptom | Cause and fix |
|---|---|
| `401` | Key missing, invalid, or unknown. Check that it is copied in full and matches the console. |
| `403` | Key is valid but rejected: the model is not on the key's whitelist, a quota or IP allowlist is exceeded, or the balance is empty. Top up or adjust the key's limits, then retry. |
| `413` | Payload too large. Trim the context or the attached files. |
| `429` | Rate limited. Retry with jittered exponential backoff (1s → 2s → 4s, capping around 30s). MirAPI sends no `Retry-After` header and does not retry for you. |
| `500` | Gateway or upstream failure. Idempotent requests are safe to retry. |

Every error message ends with a **request ID**; include it in a support ticket. OpenAI-style errors use the envelope `{"error": {"message", "type", "param", "code"}}`, where `type` is `new_api_error` (gateway side) or `upstream_error` (upstream failure).

## Billing

Cline charges through MirAPI's prepaid balance — no subscription or monthly fee, and balance never expires. Chat turns are billed per token (per 1M USD, in three tiers: input, output, cached read), and reasoning tokens count as output. When the balance runs out MirAPI returns `403`; topping up restores the same key immediately.

## Related links

- [Roo Code](/docs/integrations/roo-code)
- [Models & pricing](/docs/models)
- [Billing & top-ups](/docs/billing)
- [Errors](/docs/api-reference/errors)