Skip to main content
Build your agent on Neon and provision backends you fully control. See how Ideavo does it
/AI Gateway/Troubleshooting

AI Gateway troubleshooting

Common errors and how to fix them

View as Markdown

Authentication errors

401 invalid or missing credential

The bearer token is missing, malformed, or has been revoked.

Fix: Check that NEON_AI_GATEWAY_TOKEN is set and contains the full nt_live_... token returned when you created the credential. If the credential was revoked, create a new one. See Authentication.

403 credential not authorized for ai gateway

The credential exists but lacks the ai_gateway:invoke scope.

Fix: Create a new credential that includes ai_gateway:invoke in the scopes array. You can't add scopes to an existing credential. See Authentication.

403 credential not authorized for this branch

The credential was issued on a branch that is not an ancestor of the branch in the request hostname.

Fix: Use a credential issued on the current branch or an ancestor branch. See Authentication for how branch lineage works.

503 authorization temporarily unavailable

The credential store or branch resolver is temporarily unavailable.

Fix: Retry the request. This is a transient infrastructure error, not a client error.


Model errors

400 unknown model "<model-id>"

The model field in the request body does not match any entry in the AI Gateway catalog. The error message includes the model ID you sent.

Fix: Check the model ID against the full model catalog. Use the short form (e.g., gpt-5-mini) or the databricks- prefixed form (databricks-gpt-5-mini) — both are accepted.

400 model "<model-id>" is not available on the <endpoint> endpoint

The model exists in the catalog but doesn't work with the endpoint you're calling. The error message names both the model and the endpoint dialect it was sent to (for example, openai_responses, gemini_generate_content, or chat_completions).

Fix: Check which endpoint the model requires:

  • OpenAI codex models on /v1/chat/completions → use /openai/v1/responses
  • Google models on /openai/v1/responses → use /gemini/v1beta/... or /v1/chat/completions

See Which endpoint to use.

400 missing or invalid model

The request body does not contain a valid model field.

Fix: Include "model": "<model-id>" in the request body.

Locked models in the Console

On your project's AI Gateway page, a locked model shows a padlock. Hover over the padlock to see why the model is locked, along with a link to fix it:

TooltipWhat to do
Add a card to buy AI gateway credits for this model.Your organization is on the Free plan with no payment card on file. Select Add a card, add your card, then buy credits. You don't need to upgrade your plan. See AI Gateway prepaid credits.
AI Gateway credits are required to use this model.Select Buy credits. See AI Gateway prepaid credits.
A paid plan is required to use this model.Your organization can't buy credits on its current plan, for example because it's billed through the Vercel Marketplace. Select Upgrade plan.
Account verification is required to use this model.Neon checks your account after your first credit purchase. Wait a few minutes and reload the page. If the tooltip links to Complete verification or Contact support for verification, follow that link.
Your account has reached its daily AI Gateway spend limit.You can request a limit increase. Scale plan users can request a limit increase from the console. See Usage limits.
Your account is restricted from using this model.Contact Support.
This model is not available to your account.Contact Support.

Only organization admins can add a card or buy credits. After you buy credits, models unlock once Neon confirms access, usually within a few seconds. Reload the page if a model still shows as locked.


Gemini-specific errors

404 page not found

The request didn't reach a gateway route. The Gemini endpoint is served at /gemini/v1beta/..., but google-genai 3.x defaults to the v1 API version, so a client configured with only the base URL calls /gemini/v1/models/....

Fix: Set httpOptions.apiVersion (TypeScript) or http_options.api_version (Python) to v1beta when you configure the SDK. See Gemini API.

404 unsupported gemini action

The action in the Gemini endpoint URL is unsupported. The AI Gateway supports Gemini generateContent and streaming streamGenerateContent calls.

Fix: Use either :<model-id>:generateContent or :<model-id>:streamGenerateContent. Other actions (countTokens, etc.) are not available.

404 invalid gemini model path

The {modelAction} segment in the Gemini URL path is malformed. It must follow the format <model>:<action> where both parts are non-empty.

Fix: Ensure the URL path contains exactly one colon separating the model ID and action, e.g. gemini-3-flash:generateContent.


Workspace resolution errors

403:could not resolve workspace from host

The request host does not match the expected format.

Common cause:

  • The host does not end with a trusted suffix (.neon.tech in production).

A mistyped host usually returns 404 with an empty body before the request reaches the gateway, so you might see that instead of this error.

Fix: Verify that you are using the correct AI Gateway host from the Neon Console or API. The host format for production is <branch-id>-api.ai.<cell>.<region>.aws.neon.tech. Do not construct the host manually.


Rate limiting and quota

429: upstream provider rate limit

The request hit the upstream Databricks/provider rate limit.

Fix: Implement exponential backoff. The response includes a Retry-After header and provider-specific rate limit headers (X-Ratelimit-*). See Rate limiting.

429: account quota exceeded

Your account's AI Gateway quota is blocked. This happens when you exceed a token-per-minute (TPM) rate limit or your account's daily spend limit, or when your prepaid credit balance drops below the $2 minimum. All three return REQUEST_LIMIT_EXCEEDED, and the message names the limit that was hit and how to recover.

An account-wide TPM limit:

{
  "error_code": "REQUEST_LIMIT_EXCEEDED",
  "message": "You've exceeded your AI Gateway account input token limit (<N> input tokens per minute across all models). You can retry once the current minute resets, or ask Neon support to raise it (we review all increases to prevent abuse): https://console.neon.tech/app/projects?modal=support"
}

A per-model TPM limit names the model instead. Only the message value changes:

You've exceeded your AI Gateway input token limit for model "<model-id>" (<N> input tokens per minute). You can retry once the current minute resets, or ask Neon support to raise it (we review all increases to prevent abuse): https://console.neon.tech/app/projects?modal=support

Input and output tokens are limited separately. When the output limit is hit, the same messages say output instead of input.

A daily spend limit:

{
  "error_code": "REQUEST_LIMIT_EXCEEDED",
  "message": "You've reached your AI Gateway daily spend limit. You can retry after it resets, or ask Neon support to raise it (we review all increases to prevent abuse): https://console.neon.tech/app/projects?modal=support"
}

A credit balance below the minimum. The response includes a link to add credits:

{
  "error_code": "REQUEST_LIMIT_EXCEEDED",
  "message": "AI Gateway credit balance is below the required minimum. Add credits to continue. <recovery URL>",
  "unavailable_reason": "credits_required",
  "recovery_url": "<recovery URL>"
}

This block has no Retry-After header and doesn't clear on its own. Buy credits, or turn on automatic top-up so it doesn't happen again.

Fix: Check the Retry-After header. If present, the block is temporary and lifts at that time; retry with exponential backoff. If absent, the block lasts until it's resolved: for a low credit balance, add credits; for a limit, you can request a limit increase. Scale plan users can request a limit increase from the console. See Rate limits for current values.


Upstream errors

When the upstream model provider or Databricks returns an error, the AI Gateway replaces the upstream response body with its own {"error_code","message"} envelope and preserves the upstream status code. Upstream internal details, such as endpoints, workspace IDs, Unity Catalog objects, principals, and internal headers, are never exposed to the caller.

The message identifies the condition:

ConditionMessage
Endpoint disabledThis model is temporarily disabled. Contact Neon support for help: https://console.neon.tech/app/projects?modal=support
TimeoutThe model took too long to respond. Reduce max_tokens or your input size, or use streaming.
Request too largeai gateway upstream rejected the request: body too large
Model unavailableai gateway upstream model is not available. Contact Neon support
Access deniedai gateway upstream denied the request. Contact Neon support
Over capacityai gateway upstream model is temporarily over capacity. Retry later
Upstream internal errorai gateway upstream model error. Retry later, or contact Neon support if it persists
Invalid requestai gateway upstream model rejected the request: <provider message> (redacted to ...rejected the request as invalid when the provider detail can't be shown safely)
Unknownai gateway upstream request failed. Contact Neon support if it persists

Fix: Follow the guidance in the message. Retry transient conditions (over capacity, upstream internal error) with exponential backoff, respecting any Retry-After header. Don't retry a timeout as is: the gateway sends X-Should-Retry: false so the OpenAI and Anthropic SDKs skip their automatic retry, because each retry runs the whole slow generation again. Reduce max_tokens or the input size, or use streaming. If an error persists, check the Neon status page. For paid plan support options, see Support.


Error response formats

Errors the gateway generates itself (authentication, model validation, workspace resolution) use the standard OpenAI error envelope:

{
  "error": {
    "message": "unknown model \"<model-id>\""
  }
}

Quota blocks and all upstream (non-2xx) errors use a flat envelope, with the upstream status code preserved:

{
  "error_code": "REQUEST_LIMIT_EXCEEDED",
  "message": "You've reached your AI Gateway daily spend limit. You can retry after it resets, or ask Neon support to raise it (we review all increases to prevent abuse): https://console.neon.tech/app/projects?modal=support"
}

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Last updated on

Was this page helpful?
Edit on GitHub