> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors and troubleshooting

> What each Model Gateway and API key error means, why it happens and how to fix it.

Errors on model endpoints come in the error format of the API you call, so OpenAI and Anthropic SDKs raise their usual exceptions. Every error body also has a top level `message` with the same text. The OpenAI format looks like this:

```json theme={null}
{
  "error": {
    "message": "The Model Gateway endpoint does not serve this API key type or endpoint yet. Use the /api/public endpoint of your Langdock workspace instead.",
    "type": "permission_error",
    "param": null,
    "code": "model_gateway_unsupported"
  },
  "message": "The Model Gateway endpoint does not serve this API key type or endpoint yet. Use the /api/public endpoint of your Langdock workspace instead."
}
```

The Anthropic format has `type: "error"`, an `error` object with `type` and `message`, and the `request_id`. Platform API endpoints such as `/agent/v1/...` return a JSON object with `message`. Every response carries an `x-request-id` header. Include it when you contact support.

## Authentication (401)

| Code | Message starts with | Cause | Fix |
| - | - | - | - |
| `missing_api_key` | You didn't provide an API key | No key in the request | Send your key in `Authorization: Bearer <key>` or `x-api-key: <key>` |
| `missing_api_key` | Provide exactly one API key credential | Two keys in the request at once | Send exactly one of `Authorization: Bearer <key>` or `x-api-key: <key>` |
| `invalid_api_key` | The provided API key is invalid | Typo, truncated key, or the key was revoked or rotated | Copy the whole key again, or create a new one |
| `expired_api_key` | API key has expired | The key's expiry date passed | Create a new key |
| `api_key_owner_inactive` | The API key owner is no longer an active workspace member | The member who owns this personal key left or was deactivated | Use your own key. Shared integrations need a workspace key |
| `personal_api_keys_disabled` | Personal API keys are not enabled for this user | An admin removed your access to personal keys | Ask your workspace admin for access |

After many failed attempts from the same network, further attempts get `429` for a short time.

## Permissions (403)

| Code | Cause | Fix |
| - | - | - |
| `insufficient_scopes` | The key lacks the scope for this endpoint. For example a Platform API key on a model endpoint, a Model Gateway key on a Platform API endpoint, or a personal key whose scope your admin no longer allows | Use the right [kind of key](https://docs.langdock.com/en/developer/overview/api-keys.md), or ask your admin to allow the scope and create a new key |
| `model_gateway_not_enabled` | The Model Gateway is not enabled for you yet | Use the classic endpoint on `api.langdock.com`, or ask your admin |
| `model_gateway_unsupported` | `gateway.langdock.com` does not serve this key or endpoint yet: workspace keys, embeddings | Send the request to `api.langdock.com` |
| `gateway_access_denied` | Your workspace's access rules do not allow this request | Ask your admin which models and features you can use |

## Requests (400, 404)

| Code | Cause | Fix |
| - | - | - |
| `not_found` (404) | The path does not exist, often a doubled `/v1/v1/...` | Check the base URL. Tools that add `/v1/messages` themselves need `https://gateway.langdock.com` without `/v1` |
| `model_not_found` (404) | The model name is unknown, not enabled for API use, not available to you or not offered in this region | Use an ID from `GET /v1/models`, or ask your admin to enable the model or give you access |
| `gateway_invalid_request` (400) | A parameter or tool the model does not support, for example hosted web search on a model without it | The message names the parameter. Remove it or pick another model |
| `context_length_exceeded` (400) | The input is longer than the model's context window | Shorten the input or pick a model with a larger window |
| `invalid_request` (400) | A region the endpoint does not serve, or an invalid header | Use `eu`, `us` or `global` on the gateway |

## Limits (429)

| Code | Cause | Fix |
| - | - | - |
| `rate_limit_exceeded` | A requests or tokens per minute limit, or too many requests in progress at once | Wait the seconds in `Retry-After` and retry. Ask your admin to request a higher model quota if it keeps happening |
| `rate_limit_exceeded`, message says the provider is rate limiting | The model provider is out of capacity | Retry after `Retry-After`, or use another model |
| `insufficient_quota` | A spend limit is reached or zero: your personal limit, the workspace total, the workspace API limit, an agent budget, or extra usage is off | The message names the limit and when it resets. Ask your admin to raise it, or wait for the reset |

A token limit `429` whose message says the request alone is larger than the limit cannot succeed by retrying. Shorten the request or ask for a higher quota. See [Limits and usage](https://docs.langdock.com/en/developer/model-gateway/limits-and-usage.md).

## Server and provider errors (5xx)

| Status | Code | Fix |
| - | - | - |
| 502 | `provider_unavailable` | The model provider failed. Retry, or use another model |
| 503 | `gateway_unavailable`, `service_unavailable` | Langdock is briefly unavailable or restarting. Retry with backoff |
| 504 | `provider_unavailable` | The provider timed out. Retry, or shorten the request |

## Common setup mistakes

> [accordion] Claude Code ignores my key
>
> `ANTHROPIC_API_KEY` in your shell takes precedence over `ANTHROPIC_AUTH_TOKEN`. Unset it, restart Claude Code and check `/status`.

> [accordion] It works with curl but not in Cursor
>
> Cursor calls the base URL from its own servers and sends Claude and Gemini model names to its own keys. Add the `anthropic/` or `gemini/` prefix to those model IDs, and keep **Override OpenAI Base URL** on.

> [accordion] Embeddings fail on the gateway
>
> Embeddings are not on `gateway.langdock.com` yet. Call `https://api.langdock.com/openai/{region}/v1/embeddings` with a key that has the Embedding scope.

> [accordion] My agent call fails with insufficient\_scopes
>
> Running an agent needs **Run agents** on a Model Gateway key, or an Agent scope on a Platform API key, and the call goes to `api.langdock.com`, not to the gateway.

> [accordion] My key worked yesterday
>
> Check in your account settings whether the key expired, was revoked or was rotated, and whether your spend limit is used up. An admin can also revoke keys or change which scopes personal keys may use. Removed scopes do not come back on that key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.