Beta docs: the shipped API is POST /api/v1/generate for gemini and sarvam. Some pages below describe planned features. See the shipped quick start.

Core Concepts

Error Handling

Errors are JSON, they carry a status code, and they tell you whether to retry.

OpenLink returns errors as HTTP status codes with a single JSON envelope — the same envelope whether the failure came from your request or from a provider. The type and code fields tell you what happened; retryable tells you what to do next.

The error envelope

JSON
{
  "error": {
    "type": "provider_error",
    "code": "provider_rate_limited",
    "message": "Anthropic returned HTTP 429 after 2 retries.",
    "provider": "anthropic",
    "retryable": true,
    "request_id": "req_01J8R2aKq..."
  }
}
FieldMeaning
typeBroad class: invalid_request, auth, rate_limit, provider.
codeStable, machine-readable code. Safe to match on.
messageHuman-readable detail.
providerWhich provider was at fault, when applicable.
retryableWhether retrying the same request may succeed.
request_idCorrelates with the request in your dashboard.

HTTP status codes

StatusWhen
400Malformed body or unsupported field.
401Missing or invalid API key.
402Key has no spending attached (beta: ad-hoc).
404Unknown endpoint or model.
422The request failed validation.
429Rate limit hit. Honor Retry-After.
500Internal gateway error.
502Upstream provider error, retries exhausted.
503No healthy provider can serve the request.
529Provider is overloaded. Retryable.

Retryable errors

429, 502, and 529 responses set retryable: true. The gateway already retries internally before surfacing a provider error to you — when an error reaches your code, you are usually looking at the exhausted case.

Retry consistently

Match on error.code, not status text, so your handling stays stable as types evolve. The Retries guide covers the practical pattern.

SDK exceptions

errors.ts
try {
  await client.chat({ messages });
} catch (err) {
  if (err.status === 429) {
    const wait = Number(err.headers.get("retry-after")) * 1000;
    await sleep(wait);
    return retry();
  }
  if (err.retryable) return retry();
  throw err;
}