fx with AI Gateway
fx is a terminal coding agent with native AI Gateway support. It reads AI_GATEWAY_API_KEY directly, so you only need to configure the credential. The whole gateway catalog is available without a provider definition.
Run the Vercel CLI setup command for fx:
npx vercel ai-gateway setup --agent fxThe command exports AI_GATEWAY_API_KEY from a managed block in your shell startup file and pins credential_source in ~/.fx/settings.json to that key, ahead of a stored fx login session.
If you can't use the Vercel CLI, configure fx 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.
Set
credential_sourcein~/.fx/settings.jsonso fx uses the exported key ahead of a storedfx loginsession:~/.fx/settings.json{ "credential_source": "ai_gateway_api_key" }Open a new terminal so the key is loaded, then confirm the credential:
Terminalfx statusPick a model with
/model, or browse the catalog with/models. The whole gateway catalog is available.
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. Required |
- Run benchmark tasks with fx using Harbor
- Browse the models catalog for available models
- Configure spend limits on your API key
Was this helpful?