AI Gateway

Use Astro-provided LLM access without managing your own provider keys

View as Markdown

Set one line in your spec and your agent gets a managed API key for calling supported models — no provider account, no API keys to store, no key rotation to manage.

Quick start

Add astro_ai_gateway: true to your agent in astropods.yml:

1agent:
2 image: my-agent:latest
3 astro_ai_gateway: true

On ast deploy (and ast dev), your agent container receives two environment variables:

Env varPurpose
ASTRO_GATEWAY_URLBase URL to call.
ASTRO_GATEWAY_API_KEYBearer credential. Treat as a secret.

Wire them into the SDK or framework you’re already using. The gateway is OpenAI-API-compatible — anything that accepts a custom base URL works:

1from openai import OpenAI
2import os
3
4client = OpenAI(
5 api_key=os.environ["ASTRO_GATEWAY_API_KEY"],
6 base_url=os.environ["ASTRO_GATEWAY_URL"],
7)
8
9response = client.chat.completions.create(
10 model="claude-sonnet-4-6",
11 messages=[{"role": "user", "content": "Hello"}],
12)

For Mastra: the AI-SDK provider returned by createOpenAI is what Agent.model: accepts, so the rest of your Agent / Workflow / Tool definitions stay the same.

Supported models

Pass any of these strings as model on the SDK call:

ModelUse case
claude-opus-4-8Most capable; longer reasoning, agentic workflows.
claude-sonnet-4-6Workhorse; balanced cost / quality. Good default.
claude-haiku-4-5Fast and cheap; tool-use loops, classification.
titan-embed-text-v2Text embeddings (RAG, vector search).

Local development

ast dev handles the gateway automatically. Run:

$ast login
$ast dev project start

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:

1agent:
2 image: my-agent:latest
3 astro_ai_gateway: true # gateway-managed models
4models:
5 custom-fine-tune:
6 provider: openai # your own OpenAI key for a specific use case

Your agent code reads ASTRO_GATEWAY_API_KEY for gateway calls and OPENAI_API_KEY for the BYOK provider.

What it doesn’t cover

  • Anthropic-native SDK. Use the OpenAI SDK (or one of the frameworks above) pointed at ASTRO_GATEWAY_URL. Calling Anthropic’s native messages endpoint isn’t supported.
  • Vision / image generation. The supported model list is text-only.
  • Bring-your-own-model. Adding new models or fine-tunes to the gateway isn’t self-serve; reach out to support.