Skip to content
Docs

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:

terminal
npx vercel ai-gateway setup --agent droid

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

  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. Droid resolves ${AI_GATEWAY_API_KEY} in its settings at load time, so the key never lands in the file.

  3. 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
        }
      ]
    }

    customModels defines the whole /model picker. Droid does no model discovery, so add one entry per gateway model you want available, each with its own maxOutputTokens.

  4. Terminal
    droid

    Pick a model with /model in a session. For headless runs, always pass a gateway model:

    Terminal
    droid exec -m openai/gpt-6-astra

    droid exec defaults 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.

VariableDescription
AI_GATEWAY_API_KEYYour AI Gateway API key, read through ${AI_GATEWAY_API_KEY}. Required

Droid calls AI Gateway through the OpenAI-compatible Chat Completions API, so any model that supports Chat Completions works.

Last updated September 13, 2026

Was this helpful?

supported.