# AI Gateways diagnostics

<!-- Generated by docs/modules/diagnostics from the package catalogs. Write a guide in docs/diagnostics/<CODE>.md instead of editing this file. -->

Each AI Gateways error has a stable `code`. Its `docs` link opens the page of that code. This page lists all 21 codes, and [All diagnostics](https://vitehub.dev/docs/reference/diagnostics) lists every primitive.

## Runtime errors

| Code | What happened |
| --- | --- |
| [`GATEWAYS_R0001`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0001) | languageModel(gateway, modelId) needs a gateway from a preset or defineAiGateway(). For chatgpt(), set driver: { model, gateway: chatgpt() } on an Agent. |
| [`GATEWAYS_R0002`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0002) | Gateway "\<name\>" needs an API key for the "\<api\>" model API. Pass apiKey, or use api: "chat". |
| [`GATEWAYS_R0003`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0003) | Gateway "\<name\>" header "\<name\>" resolved to an empty value. |
| [`GATEWAYS_R0004`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0004) | Gateway "\<name\>" does not serve the "\<api\>" model API. Choose api: \<value\>. |
| [`GATEWAYS_R0005`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0005) | Gateway "\<name\>" routes model requests and cannot answer Jev questions. Use typesafe(), vercel(), or cloudflare() for ask(). |
| [`GATEWAYS_R0006`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0006) | TypeSafe Jev requests require the advocaat package. Install it with: pnpm add advocaat |
| [`GATEWAYS_R0007`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0007) | Question "\<name\>" must be built with ask.choice(), ask.score(), ask.chance(), ask.if(), or ask.switch(). |
| [`GATEWAYS_R0008`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0008) | The \<provider\> Jev provider rejected the API key with HTTP \<status\>. The key is missing, expired, or not allowed to call Jev. |
| [`GATEWAYS_R0009`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0009) | The \<provider\> Jev provider failed\<value\> after \<attempts\> attempts. |
| [`GATEWAYS_R0010`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0010) | The "\<api\>" model API needs the \<value\> package. Install it with: pnpm add \<value\> |
| [`GATEWAYS_R0011`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0011) | \<caller\> requires the ai package. Install it with: pnpm add ai |
| [`GATEWAYS_R0012`](https://vitehub.dev/docs/gateways/diagnostics/gateways_r0012) | The model did not answer question "\<name\>" with one of its options. |

## Named errors

| Code | What happened |
| --- | --- |
| [`GATEWAYS_ASK_EACH_KEY_DUPLICATE`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_each_key_duplicate) | ask.each produced duplicate key \<key\> |
| [`GATEWAYS_ASK_EACH_KEY_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_each_key_invalid) | ask.each keys must be non-empty strings |
| [`GATEWAYS_ASK_MODEL_FAILED`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_model_failed) | The ask() model request failed\<value\>. |
| [`GATEWAYS_ASK_OUTPUT_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_output_invalid) | The model answer to ask() has no text. The model stopped with finish reason "\<finishReason\>". |
| [`GATEWAYS_ASK_PROMPT_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_prompt_invalid) | ask() needs a non-empty prompt string |
| [`GATEWAYS_ASK_SCHEMA_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_schema_invalid) | ask() needs a schema that converts to JSON Schema, and this \<vendor\> schema does not |
| [`GATEWAYS_ASK_THRESHOLD_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_ask_threshold_invalid) | ask.if threshold must be a finite number |
| [`GATEWAYS_JEV_INPUT_TOO_LARGE`](https://vitehub.dev/docs/gateways/diagnostics/gateways_jev_input_too_large) | Jev question "\<question\>" exceeds the safe per-question input budget. |
| [`GATEWAYS_JEV_RESPONSE_INVALID`](https://vitehub.dev/docs/gateways/diagnostics/gateways_jev_response_invalid) | Jev choice answer "\<name\>" is missing a valid probability distribution. |

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/gateways.md)
- [Get started](https://vitehub.dev/raw/docs/gateways/get-started.md)
- [Configure](https://vitehub.dev/raw/docs/gateways/configure.md)
- [Server API](https://vitehub.dev/raw/docs/gateways/server-api.md)
- [Limits and errors](https://vitehub.dev/raw/docs/gateways/limits-and-errors.md)
- [Use with Agents](https://vitehub.dev/raw/docs/gateways/agents.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
