Repository navigation
Model Providers
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.
| 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_URLandFAI_LLM_API_KEY), both inconfig.toml, or both on the command line (--base-urland--api-key).FAI_LLM_API_KEYtogether with--base-urlsends no key.
# 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/v1On Windows PowerShell, set a key with $env:DEEPSEEK_API_KEY = "...".
provider = "auto" (the default in config.toml) decides in this order:
- A
base_urlon one of the known endpoints above selects that provider. Any otherbase_urluses the OpenAI-compatible protocol. - A model name starting with
claudeselects Anthropic, and one starting withgeminiselects Gemini. - An API key given directly selects OpenAI, or OpenCode Go when it starts with
oc_sk_. - Otherwise the first key found among
ANTHROPIC_API_KEY,DEEPSEEK_API_KEY,OPENAI_API_KEY,OPENROUTER_API_KEY,OPENCODE_API_KEYandGEMINI_API_KEY/GOOGLE_API_KEY, in that order.
If more than one key is set, pass --provider to be explicit.
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 everyoneUse the token limits to cap spending. Keep keys in environment variables rather than in config.toml if the file
is shared. More in Configuration.
Repository · Releases · Issues · MIT licence · Factorio is a trademark of Wube Software Ltd. This project is not affiliated with Wube Software.
Getting started
Playing
Developing
中文