Files
coder/docs/ai-coder/ai-gateway/clients/factory.md
T
Yevhenii ShcherbinaandSusana Ferreira 95fd3e5e23 docs: use coder-api-token instead of coder-session-token (#24316)
## Summary

Follows up on https://github.com/coder/coder/pull/24032
Renames "Coder session token" to "Coder API token" in AI Gateway client
documentation pages.
Also renames the `CODER_SESSION_TOKEN` env var to `CODER_API_TOKEN` in
Codex CLI examples and Copilot proxy configuration.

Note: "Coder session token" is still used in some parts of the
documentation where it make sense.

---------

Co-authored-by: Susana Ferreira <susana@coder.com>
2026-04-14 16:14:48 -04:00

2.4 KiB

Factory

Factort's Droid agent can be configured to use AI Gateway by setting up custom models for OpenAI and Anthropic.

Centralized API Key

  1. Open ~/.factory/settings.json (create it if it does not exist).
  2. Add a customModels entry for each provider you want to use with AI Gateway.
  3. Replace coder.example.com with your Coder deployment URL.
  4. Use a Coder API token for apiKey.
{
  "customModels": [
    {
      "model": "claude-sonnet-4-5-20250929",
      "displayName": "Claude (Coder AI Bridge)",
      "baseUrl": "https://coder.example.com/api/v2/aibridge/anthropic",
      "apiKey": "<your-coder-api-token>",
      "provider": "anthropic",
      "maxOutputTokens": 8192
    },
    {
      "model": "gpt-5.2-codex",
      "displayName": "GPT (Coder AI Bridge)",
      "baseUrl": "https://coder.example.com/api/v2/aibridge/openai/v1",
      "apiKey": "<your-coder-api-token>",
      "provider": "openai",
      "maxOutputTokens": 16384
    }
  ]
}

BYOK (Personal API Key)

  1. Open ~/.factory/settings.json (create it if it does not exist).
  2. Add a customModels entry for each provider you want to use with AI Bridge.
  3. Replace coder.example.com with your Coder deployment URL.
  4. Use your personal API key for apiKey.
  5. Set the X-Coder-AI-Governance-Token header to your Coder API token.
{
  "customModels": [
    {
      "model": "claude-sonnet-4-5-20250929",
      "displayName": "Claude (Coder AI Bridge)",
      "baseUrl": "https://coder.example.com/api/v2/aibridge/anthropic",
      "apiKey": "<your-anthropic-api-key>",
      "provider": "anthropic",
      "maxOutputTokens": 8192,
      "extraHeaders": {
        "X-Coder-AI-Governance-Token": "<your-coder-api-token>"
      }
    },
    {
      "model": "gpt-5.2-codex",
      "displayName": "GPT (Coder AI Bridge)",
      "baseUrl": "https://coder.example.com/api/v2/aibridge/openai/v1",
      "apiKey": "<your-openai-api-key>",
      "provider": "openai",
      "maxOutputTokens": 16384,
      "extraHeaders": {
        "X-Coder-AI-Governance-Token": "<your-coder-api-token>"
      }
    }
  ]
}

References: Factory BYOK OpenAI & Anthropic