Skip to content

Model Providers

saudademjj edited this page Dec 5, 2026 · 1 revision

The in-game agent (fai agent) works with several model providers and with any OpenAI-compatible endpoint. The MCP server (fai-mcp) does not call a model itself: your MCP client brings its own (see Using MCP Clients).

The Windows launcher uses DeepSeek only. For anything else, start the agent from the command line.

Providers and defaults

Provider --provider API key variable Default model Default endpoint
DeepSeek deepseek DEEPSEEK_API_KEY deepseek-flash https://api.deepseek.com
OpenAI openai OPENAI_API_KEY gpt-4.1 https://api.openai.com/v1
Anthropic anthropic ANTHROPIC_API_KEY claude-sonnet-4-5 https://api.anthropic.com
Google Gemini gemini GEMINI_API_KEY or GOOGLE_API_KEY gemini-2.5-pro https://generativelanguage.googleapis.com/v1beta
OpenRouter auto with --base-url https://openrouter.ai/api/v1 OPENROUTER_API_KEY anthropic/claude-sonnet-4
OpenCode Go opencode-go OPENCODE_API_KEY deepseek-v4.1-flash https://opencode.ai/inference/go/openai/v1
Any OpenAI-compatible endpoint openai with a base URL FAI_LLM_API_KEY or --api-key gpt-4.1; pass --model with a model your endpoint serves your URL

--model overrides the default model. deepseek and opencode-go only accept their official endpoints.

Keys follow their endpoint. When the base URL changes, a key configured for the old URL is dropped, so it is never sent to a different service. Set the URL and the key the same way: both as environment variables (FAI_LLM_BASE_URL and FAI_LLM_API_KEY), both in config.toml, or both on the command line (--base-url and --api-key). FAI_LLM_API_KEY together with --base-url sends no key.

Examples

# DeepSeek
export DEEPSEEK_API_KEY=...
fai agent --provider deepseek

# Anthropic with a chosen model
export ANTHROPIC_API_KEY=...
fai agent --provider anthropic --model claude-sonnet-4-5

# Any OpenAI-compatible service, for example xAI
export FAI_LLM_BASE_URL=https://api.x.ai/v1
export FAI_LLM_API_KEY=...
fai agent --provider openai --model <model id>
# or everything on the command line:
fai agent --provider openai --base-url https://api.x.ai/v1 --api-key ... --model <model id>

# A local Ollama: no key needed, the default model on port 11434 is qwen2.5:14b
fai agent --provider openai --base-url http://localhost:11434/v1

On Windows PowerShell, set a key with $env:DEEPSEEK_API_KEY = "...".

How auto picks a provider

provider = "auto" (the default in config.toml) decides in this order:

  1. A base_url on one of the known endpoints above selects that provider. Any other base_url uses the OpenAI-compatible protocol.
  2. A model name starting with claude selects Anthropic, and one starting with gemini selects Gemini.
  3. An API key given directly selects OpenAI, or OpenCode Go when it starts with oc_sk_.
  4. Otherwise the first key found among ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, OPENAI_API_KEY, OPENROUTER_API_KEY, OPENCODE_API_KEY and GEMINI_API_KEY/GOOGLE_API_KEY, in that order.

If more than one key is set, pass --provider to be explicit.

Settings in config.toml

The same choices can live in the [agent] section, and FAI_LLM_PROVIDER, FAI_LLM_MODEL, FAI_LLM_BASE_URL and FAI_LLM_API_KEY override them:

[agent]
provider = "auto"
model = ""
base_url = ""
api_key = ""
chat_only = false          # true: only answer @ai chat, not events such as power shortages or attacks
max_tool_rounds = 12
max_session_tokens = 0     # stop after this many input + output tokens in one run, 0 = no limit
max_daily_tokens = 0       # per ledger and UTC day, 0 = no limit
allowed_players = []       # players who may use @ai; empty allows everyone

Use the token limits to cap spending. Keep keys in environment variables rather than in config.toml if the file is shared. More in Configuration.

Clone this wiki locally