Factory Droid with AI Gateway
Factory Droid is Factory's terminal coding agent. It supports bring-your-own-key custom models, which you can point at AI Gateway for unified model access and spend monitoring.
Run the Vercel CLI setup command for Factory Droid:
npx vercel ai-gateway setup --agent droidThe command writes BYOK customModels entries into ~/.factory/settings.json referencing AI_GATEWAY_API_KEY through Droid's environment-variable syntax, with a picker shortlist of the top gateway models ranked by leaderboard spend. Re-run it to refresh the list.
If you can't use the Vercel CLI, configure Factory Droid manually:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Export the key in your shell:
Terminalexport AI_GATEWAY_API_KEY="your-ai-gateway-api-key"To persist the key, add the same line to your shell's startup file. Droid resolves
${AI_GATEWAY_API_KEY}in its settings at load time, so the key never lands in the file.Add BYOK entries to
~/.factory/settings.json:~/.factory/settings.json{ "customModels": [ { "model": "openai/gpt-6-astra", "displayName": "openai/gpt-6-astra", "baseUrl": "https://ai-gateway.vercel.sh/coding-agent/v1", "apiKey": "${AI_GATEWAY_API_KEY}", "provider": "generic-chat-completion-api", "maxOutputTokens": 128000 } ] }customModelsdefines the whole/modelpicker. Droid does no model discovery, so add one entry per gateway model you want available, each with its ownmaxOutputTokens.- Terminal
droidPick a model with
/modelin a session. For headless runs, always pass a gateway model:Terminaldroid exec -m openai/gpt-6-astradroid execdefaults to a Factory-hosted model that your gateway key can't use, so name a gateway model explicitly.
View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.
| Variable | Description |
|---|---|
AI_GATEWAY_API_KEY | Your AI Gateway API key, read through ${AI_GATEWAY_API_KEY}. Required |
- Browse the models catalog for available models
- Configure spend limits on your API key
- Read the Factory documentation for Droid options
Was this helpful?