Skip to content
Docs

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:

terminal
npx vercel ai-gateway setup --agent fx

The 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:

  1. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  2. Export the key in your shell:

    Terminal
    export AI_GATEWAY_API_KEY="your-ai-gateway-api-key"

    To persist the key, add the same line to your shell's startup file.

  3. Set credential_source in ~/.fx/settings.json so fx uses the exported key ahead of a stored fx login session:

    ~/.fx/settings.json
    {
      "credential_source": "ai_gateway_api_key"
    }
  4. Open a new terminal so the key is loaded, then confirm the credential:

    Terminal
    fx status

    Pick 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.

VariableDescription
AI_GATEWAY_API_KEYYour AI Gateway API key. Required
Last updated September 13, 2026

Was this helpful?

supported.