Skip to main content

AI Gateway

For AI agents: see llms.txt for the complete documentation index. Markdown versions are available by adding .md to a page URL or requesting Accept: text/markdown.

The Convex AI Gateway is a managed service that lets your app talk to LLMs from actions. Convex holds the provider credentials, so you don't need to obtain, store, or rotate a key. Your action authenticates with a short-lived token scoped to your deployment.

The AI Gateway is in beta

The AI Gateway is currently a beta feature. If you have feedback or feature requests, let us know on Discord!

const { text } = await generateText({
model: convexGateway("anthropic/claude-sonnet-4.5"),
prompt,
});

See Getting started for the full setup.

Supported endpoints

EndpointWhat it does
GET /v1/modelsList available models
POST /v1/chat/completionsChat completions, streaming and non-streaming

/v1/embeddings and other endpoints are coming soon. An unsupported path returns 400 with unsupported_endpoint.

See HTTP API for the request and response shapes.

Who can use it

The AI Gateway is available to teams on a paid plan. It works on Convex Cloud deployments, both production and development. If your team or deployment can't use it, getting a token fails with one of these errors:

SituationErrorWhat to do
Free plan, or gateway disabled for the teamAiGatewayDisabledUpgrade, or email support@convex.dev if this looks wrong
Local backend or self-hostedAiGatewayUnavailableCall the provider with your own key (environment variable)

Without the gateway

If you don't want to use the AI Gateway, store your provider API key as an environment variable and call the provider SDK from an action.