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 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
| Endpoint | What it does |
|---|---|
GET /v1/models | List available models |
POST /v1/chat/completions | Chat 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:
| Situation | Error | What to do |
|---|---|---|
| Free plan, or gateway disabled for the team | AiGatewayDisabled | Upgrade, or email support@convex.dev if this looks wrong |
| Local backend or self-hosted | AiGatewayUnavailable | Call 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.