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. /login opens the same picker.

ProviderConnect withIn /providerTerminal command
CodexChatGPT Plus, Pro, Business, Enterprise, or Edu subscriptioncodexfx login codex
GrokSuperGrok or X Premium subscriptiongrokfx login grok
AI GatewayVercel account or API keyvercel, then oauth for an account or api-key for a keyfx login vercel for an account, or fx login vercel --api-key for a key

fx login codex, fx login grok, and fx login vercel also make that provider active. Without a provider name, fx login signs in to Vercel.

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 providers from your terminal, run fx provider codex, fx provider grok, or fx provider gateway. If you haven't connected that subscription yet, fx provider signs you in first.

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 login vercel --api-key

fx saves the key in the macOS Keychain, or in ~/.fx/api-key on Linux. fx setup still saves a key the same way, with a warning that points to this command. It stops working in fx 0.0.18.

In fx, you can instead choose vercel, then api-key in /provider and paste the key, choosing new first if fx already has one. fx checks the key with AI Gateway before saving it, then makes it active.

For 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. Choose vercel, then oauth for your Vercel login, or api-key and then env for AI_GATEWAY_API_KEY, saved for the key fx saved, or new to paste another. fx lists env and saved only when it finds that key.

Choosing a source saves that exact source for later runs. fx login vercel and fx teams save your Vercel login the same way. A saved source takes priority over VERCEL_OIDC_TOKEN and AI_GATEWAY_API_KEY. If the chosen source is unavailable, fx reports it instead of switching accounts. fx logout vercel clears the saved source.

When no Gateway credential source is saved, fx checks credentials in this order:

SourceSelected when
VERCEL_OIDC_TOKENThe environment contains a non-empty OIDC token.
AI_GATEWAY_API_KEYThe environment contains a non-empty API key but no OIDC token.
Vercel loginNeither environment credential resolves, and the saved login can be loaded or refreshed.
Saved API keyThe key is available and none of the earlier sources resolves.

Environment values apply to fx processes started with them. fx login vercel --api-key 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:

ProviderCommand
ChatGPT subscriptionfx logout codex
Grok subscriptionfx logout grok
Vercel loginfx logout vercel

Without a provider name, fx logout signs out of Vercel. Signing out of Vercel doesn't remove a saved API key.

Signing out also ends the login at its provider, so a copy of its tokens stops working. If the provider doesn't confirm that, fx tells you, and still removes the login from this computer.

fx then keeps the tokens where the login was saved and tries again later: at the next fx login or fx logout for that provider, and each time you start fx. It deletes them once the provider confirms the sign-out, or after 30 days. When a retry can't help, such as when the provider has no way to end a login, fx says so and keeps nothing.

In fx, /logout signs out of the active provider, or of the one you name, such as /logout codex. If you sign out of the subscription you're using, fx switches to another connected provider when one is available.

Change Vercel team

fx teams chooses the AI Gateway team for your saved Vercel login, selects that login for Gateway requests, and switches fx to AI Gateway. Once you're signed in, choosing vercel, then oauth in /provider lists the same teams. The chosen team determines the models and credits available to fx. API keys and environment credentials do not use this team selection.

When you sign in to Vercel again, fx starts on the team you used before, so pressing Enter keeps it. This also holds in another fx session or after a restart: when fx removes a login that has expired, it keeps that login's team, without its tokens, in ~/.fx/vercel-team.json. fx logout vercel forgets it. If your account no longer has that team, fx starts on the first team in the list. In fx login and fx teams, (current) marks the team your login uses now.