Authentication
Connect the account or API key fx should use for model requests.
Model providers
Open fx and run /provider to choose where fx sends model requests and how you connect.
| Provider | Connect with | Terminal command |
|---|---|---|
| Codex | ChatGPT subscription | fx login codex |
| Grok | Grok subscription | fx login grok |
| AI Gateway | Vercel account or API key | fx login vercel for an account, or fx setup for a key |
Your provider determines the available models and where usage is billed. fx remembers the model you selected for each provider. Use /model to choose another one, or learn more about models.
To switch an existing connection from your terminal, run fx provider codex, fx provider grok, or fx provider gateway.
Custom endpoints
You can also connect Ollama, vLLM, OpenRouter, or another compatible Chat Completions endpoint. Define it in ~/.fx/settings.json, then select it with fx provider <name> or FX_PROVIDER.
Custom connections can run without authentication or read a bearer key from an environment variable. See Custom model connections for examples and supported fields.
Use an AI Gateway API key
Create an AI Gateway API key, then save it with:
fx setupFor a script or CI job, set AI_GATEWAY_API_KEY and select Gateway:
export AI_GATEWAY_API_KEY="your-api-key"
fx provider gateway
fx ask "Summarize this repository"
Credential selection
Use /provider to choose which AI Gateway credential fx should use. Choosing a Vercel login or API-key source saves that exact source for later runs. It takes priority over VERCEL_OIDC_TOKEN and AI_GATEWAY_API_KEY. If the chosen source is unavailable, fx reports it instead of switching accounts.
When no Gateway credential source is saved, fx checks credentials in this order:
| Source | Selected when |
|---|---|
VERCEL_OIDC_TOKEN | The environment contains a non-empty OIDC token. |
AI_GATEWAY_API_KEY | The environment contains a non-empty API key but no OIDC token. |
| Vercel login | Neither environment credential resolves, and the saved login can be loaded or refreshed. |
| Saved API key | The key is available and none of the earlier sources resolves. |
Environment values apply to fx processes started with them. fx setup saves a key but does not select it. Without a saved choice, fx reaches that key through the order above. Use /provider to select it explicitly.
Manage connections
Run fx status or /status to see the active provider, model, and credential source.
To sign out from your terminal:
| Provider | Command |
|---|---|
| ChatGPT subscription | fx logout codex |
| Grok subscription | fx logout grok |
| Vercel AI Gateway | fx logout vercel |
In fx, /logout signs out of the active provider.
Change Vercel team
fx teams chooses the AI Gateway team for your saved Vercel login and selects that login for Gateway requests. The chosen team determines the models and credits available to fx. API keys and environment credentials do not use this team selection.