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 call AI models 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.

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

See Getting started for the full setup.

Supported endpoints​

Text generation​

See Getting started for text generation and embedding examples.

EndpointWhat it does
GET /v1/modelsList available models
POST /v1/chat/completionsChat completions, streaming and non-streaming
POST /v1/embeddingsGenerate embeddings
POST /v1/messagesAnthropic Messages, streaming and non-streaming
POST /v1/responsesOpenAI Responses, streaming and non-streaming

Decisions with Jev​

Call /alpha/decisions to classify or score data with Jev. See Decisions for the request format.

Decisions is in alpha

The /alpha/decisions request and response format may change during alpha.

Images and videos​

EndpointWhat it does
POST /v1/images/generationsGenerate images
POST /v1/videos/generationsWait for a video and download it
POST /v1/videosStart an async video job
POST /v1/videos/statusCheck an async job
POST /v1/videos/downloadDownload a completed async video

See Images and videos for SDK examples and async availability requirements.

Image and video generation are in alpha

The request and response format may change during alpha.

Speech and transcription​

EndpointWhat it does
POST /v1/audio/transcriptionsTranscribe audio
POST /v1/audio/speechGenerate spoken audio

See Voice for SDK examples and for audio chat models.

Voice is in alpha

The request and response format may change during alpha.

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 production and development deployments, and on local deployments linked to a Convex project.

If your team or deployment can't use the gateway, 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
Anonymous or outdated local deploymentAiGatewayUnavailableLog in, update the Convex CLI, then restart npx convex dev and accept the backend upgrade if prompted
Self-hosted deploymentAiGatewayUnavailableCall the provider with your own key, stored as an environment variable
Local deployment of a team over its spending limitSpendingLimitExceededRaise the limit in the dashboard, or wait for it to reset
Local deployment of a suspended teamTeamSuspendedEmail support@convex.dev

Calls made with a deploy key, or by a dashboard member, also need a role that allows the AI Gateway. End users of your app need no extra permission.

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.