AI Gateway
Use Astro AI-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:
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.