
# Troubleshooting guide

This page indexes known error codes, symptoms, and resolution steps observed across the Gateway, approval framework, credential management, and model routing surfaces.

## Gateway errors

| Code | Meaning | Resolution |
|---|---|---|
| `INVALID_REQUEST` | The request body failed basic validation (e.g. missing `messages` array). | Check the request format against the [chat completions API](/docs/gateway/overview). |
| `MESSAGES_REQUIRED` | The chat completions endpoint requires at least one message in the `messages` array. | Add a `messages` array with at least one entry. |
| `SETUP_REQUIRED` | An AI provider is not configured for the requested route. | Configure a provider API key via the Gateway dashboard or BYOK. |
| `PROVIDER_UNAVAILABLE` | The upstream AI provider could not complete the request. | The request was forwarded to fallback providers if configured. If no fallback succeeded, check provider health in the Gateway dashboard. |
| `PROVIDER_NOT_IMPLEMENTED` | The selected provider is known but not yet wired for live execution. | Choose a different provider or route. |
| `INTERNAL_ERROR` | Unexpected server error. | Retry the request. If it persists, check Gateway server logs. |

## Authentication and API key errors

| Code | Meaning | Resolution |
|---|---|---|
| `missing_api_key` | The request did not include an API key in the `Authorization` header. | Add `Authorization: Bearer <your-key>` to the request headers. |
| `invalid_api_key` | The provided API key is not recognised. | Verify the key was created and has not been revoked. Keys are hashed with SHA-256 + salt and cannot be recovered. |
| `revoked_api_key` | The API key has been revoked and is no longer valid. | Create a new API key in the Gateway dashboard. |
| `expired_api_key` | The API key has passed its expiration date. | Create a new API key or update the expiration. |
| `insufficient_scope` | The key lacks the required scope for the requested operation. | Ensure the key has the `gateway:invoke` scope for chat completions. |

## Provider credential errors

| Symptom | Likely cause | Check |
|---|---|---|
| Gateway returns `SETUP_REQUIRED` for a provider | Provider API key is not configured (no environment variable and no BYOK credential) | Set the provider's environment variable or store a BYOK credential. |
| `test_failed` credential status | The stored credential failed a connectivity test | Verify the key is valid in the provider's dashboard. |
| Desktop shows "Credential not available" | Electron `safeStorage` is unavailable | Use environment variables as fallback. |

## Approval errors

| Symptom | Likely cause | Check |
|---|---|---|
| Approval request shows `stale` status | The payload hash no longer matches the current state | Re-submit the approval request with updated content. |
| Approval request shows `blocked` status | Policy prohibits the action at the configured risk level | Review the approval policy configuration. |
| Approval request expired before a decision | The `expiresAt` timeout was reached | Create a new request with a longer expiry window. |

## Model routing errors

| Symptom | Likely cause | Check |
|---|---|---|
| Requested model not available | The model is not in the Gateway model catalog or is restricted by provider allowlist | Check the [model catalog](/docs/models/overview). |
| Provider skipped in routing | Circuit breaker open, provider not configured, or blocked by allowlist | Check provider health in the Gateway dashboard. |
| Request fails with no fallback | All eligible providers are unavailable | Verify at least one provider is configured and has a closed circuit breaker. |

## See also

- [FAQ](/docs/resources/faq)
- [Status and support](/docs/resources/status-and-support)
- [Gateway overview](/docs/gateway/overview)
- [Authentication and API keys](/docs/gateway/authentication)
