AI Gateway
Use Astropods-provided LLM access without managing your own provider keys
Set one line in your spec and your agent gets a managed API key for calling supported models. The gateway is OpenAI-API-compatible, so it works with the SDKs and frameworks you already use.
Quick start
Scaffold a new agent wired to the gateway in one step:
This generates a gateway model in the spec and agent code that reads the injected env vars, with no provider key to configure. To enable the gateway on an existing agent, declare a model with provider: gateway in astropods.yml and list the models you want to choose between:
The models list is a menu of options. At deploy time, in the web console and CLI, you pick one, and it is injected as MODEL_<NAME> (here MODEL_DEFAULT). Your agent code reads the model id from that env var.
The agent.astro_ai_gateway: true boolean is deprecated in favor of a provider: gateway model. It still works (it enables the gateway with no deploy-time model selection), but declaring a gateway model is preferred and lets you pick the model at deploy.
Injected environment variables
On ast deploy (and ast project), your agent container receives:
Let chat users switch models
Your agent can let people pick a model in chat. Pass the models it accepts to serve(); the first is the default. With two or more, the chat composer shows a model picker, and chat accepts only those models.
The agent reads the picked model for each turn. With Mastra it is requestContext.get("model"). With the AI SDK, map turn.model into your call options with callOptions and return the model from prepareCall. With LangChain, read configurable["model"]. A turn with no pick, such as a Slack message, uses your default.
The list does not have to come from the gateway. An agent with its own provider keys can list provider/model ids, such as anthropic/claude-opus-4-7. Agents created with ast create start with a one-model MODELS list; add a model to it to show the picker.
Local development
ast project handles the gateway automatically. Run:
Your local agent container receives the same ASTRO_GATEWAY_* env vars it would have in production. Code written against those env vars works identically in dev and prod.
Run ast login first if you haven’t. The gateway is account-scoped, so the CLI needs to know who you are.
Mixing with your own keys
astro_ai_gateway: true is independent of any models you declare. You can use the gateway for some calls and your own provider key for others:
Your agent code reads ASTRO_GATEWAY_API_KEY for gateway calls and OPENAI_API_KEY for the bring-your-own-key (BYOK) provider.