Unlock AI-powered diplomacy, dynamically generated historical events, and a strategic advisor by connecting any AI provider — from free local models to premium cloud APIs.
Open Historia supports five types of AI providers from a single settings panel. You can switch between them at any time:
/v1/chat/completions protocol (Ollama, LM Studio, llama.cpp, DeepSeek, Groq, Together.ai, OpenRouter, and more)For providers that don't send CORS headers from the browser (OpenAI, OpenAI Compatible, Anthropic Compatible), the game's Express server includes a /api/ai/relay endpoint that proxies requests securely. Gemini and Anthropic's native APIs support direct browser access and don't use the relay.
Gemini is the default provider and the easiest way to get started. Google offers a free tier on Google AI Studio that's more than enough for solo play.
Go to Google AI Studio, sign in with a Google account, and click "Create API Key." It's free — no billing setup required.
The default gemini-2.5-flash-lite works great out of the box. You can switch to gemini-2.5-flash or gemini-2.5-pro for stronger reasoning (check rate limits on the free tier).
In the game's settings, select Gemini as the provider and paste your API key. No endpoint URL needed.
Use OpenAI's official API for GPT-4o, GPT-4.1, or o-series reasoning models. Requires a paid API account with pre-loaded credits.
Sign up at platform.openai.com, add a payment method, and create an API key under "API Keys."
gpt-4.1-mini is fast and inexpensive, gpt-4.1 handles complex diplomacy, and o4-mini excels at strategic reasoning.
Select OpenAI as the provider, paste your API key, and optionally specify a model. The endpoint is pre-configured.
Use Anthropic's Claude via the Messages API. Known for nuanced writing and strong instruction-following — excellent for immersive diplomacy and rich event generation.
Sign up at console.anthropic.com and generate an API key.
claude-sonnet-4-20250514 offers the best balance of quality and speed. claude-haiku-3-5-20241022 is faster and cheaper.
Select Anthropic as the provider and paste your API key. Direct browser access — no relay needed.
DeepSeek offers powerful models at very low cost. Their API is OpenAI-compatible, so it works through the "OpenAI Compatible" provider option.
Register at platform.deepseek.com, top up credits (minimum $2), and create an API key.
DeepSeek's API base URL is https://api.deepseek.com/v1. The model deepseek-chat covers most needs; deepseek-reasoner is available for complex strategic reasoning.
Select OpenAI Compatible as the provider. Set the endpoint to https://api.deepseek.com/v1, enter your API key, and set the model to deepseek-chat.
Run models entirely on your own hardware. No API keys, no internet required after download, completely private. Use the OpenAI Compatible provider in settings.
Ollama is the simplest way to run LLMs locally. Works on Windows, macOS, and Linux.
Download from ollama.com and install.
ollama pull llama3.2 — or any model you prefer. Recommended: llama3.2 (lightweight), mistral (balanced), qwen2.5 (strong reasoning).
Select OpenAI Compatible, set the endpoint to http://localhost:11434/v1. No API key needed for local use.
LM Studio provides a graphical interface for downloading and running models. Great for Windows and macOS users who prefer a GUI.
Download from lmstudio.ai.
Use the built-in model browser to search and download a model (e.g., Llama 3.2, Mistral 7B, Phi-3).
Go to the "Local Server" tab, load your model, and click "Start Server." The default URL is http://localhost:1234/v1.
Select OpenAI Compatible, set the endpoint to http://localhost:1234/v1. No API key needed.
llama.cpp is the most performant option for technical users. Runs GGUF-format models with minimal overhead.
Follow the build instructions for your platform.
Get a GGUF model from Hugging Face (e.g., Llama-3.2-3B-Instruct-Q4_K_M.gguf).
./llama-server -m model.gguf --port 8080
Select OpenAI Compatible, set the endpoint to http://localhost:8080/v1.
Any cloud service that speaks the OpenAI chat completions protocol works through the OpenAI Compatible provider. Popular options:
| Service | Endpoint URL | Notable |
|---|---|---|
| Groq | https://api.groq.com/openai/v1 |
Fast inference, generous free tier |
| Together.ai | https://api.together.xyz/v1 |
Wide model selection, $1 free credit |
| OpenRouter | https://openrouter.ai/api/v1 |
Access 300+ models through one API |
| DeepInfra | https://api.deepinfra.com/v1/openai |
Open-source models, pay-per-token |
| Fireworks | https://api.fireworks.ai/inference/v1 |
Fast, serverless GPU inference |
For any of these, select OpenAI Compatible, paste the endpoint URL and your API key from that service, and set the model name. The relay handles CORS automatically.
| Provider | Cost | Quality | Privacy | Best For |
|---|---|---|---|---|
| Gemini | Free tier available | Excellent | Cloud | Quickest setup, casual play |
| OpenAI | Pay-per-token | Excellent | Cloud | Best quality, heavy use |
| Anthropic Claude | Pay-per-token | Excellent | Cloud | Rich narrative, diplomacy |
| DeepSeek | Very low cost | Very good | Cloud (China) | Budget-friendly quality |
| Ollama / LM Studio / llama.cpp | Free | Varies by model | Fully local | Privacy, offline play |
| Groq / Together / OpenRouter | Free tier / low cost | Very good | Cloud | Fast cloud inference, many models |
| Model | Provider | Best For | Notes |
|---|---|---|---|
| Gemini 2.5 Flash | Google (native) | All features, great free tier | Default — excellent all-rounder |
| Gemini 2.5 Flash Lite | Google (native) | Budget / free tier | Fast, generous rate limits |
| GPT-4.1 Mini | OpenAI (native) | Fast, inexpensive | Good for diplomacy and events |
| GPT-4.1 | OpenAI (native) | Complex strategy & narrative | Top-tier quality, higher cost |
| o4-mini | OpenAI (native) | Strategic reasoning | Reasoning model, excels at planning |
| Claude Sonnet 4 | Anthropic (native) | Nuanced diplomacy, rich narrative | Best writing quality |
| DeepSeek-Chat (V3) | DeepSeek (compatible) | Budget-friendly quality | Very low cost per token |
| Llama 3.2 3B | Local (Ollama / LM Studio) | Diplomacy chat, advisor | ~4 GB RAM needed |
| Mistral 7B | Local (Ollama / LM Studio) | Events, diplomacy, advisor | ~8 GB RAM needed |
| Qwen 2.5 7B | Local (Ollama / LM Studio) | Strong reasoning, all features | ~8 GB RAM needed |
For local models: smaller models respond faster and use less RAM. Larger models generate richer events and better strategic advice. For cloud models: Gemini's free tier is the best starting point; DeepSeek offers the best quality-per-dollar.
Make sure your provider is configured correctly. For cloud APIs, verify your API key is valid and has credits. For local backends, check that the server is running and the endpoint URL matches. The game checks connectivity on load — if the backend isn't reachable, AI features won't activate.
Double-check you've selected the correct provider in settings. A Gemini key won't work with the OpenAI provider, and vice versa. For OpenAI Compatible providers, ensure the endpoint URL includes the full base path (e.g., https://api.deepseek.com/v1, not just https://api.deepseek.com).
For local models: try a smaller model (3B parameters) or enable GPU acceleration. Ollama and LM Studio both support GPU offloading. For cloud APIs: slower models like GPT-4.1 or Claude Sonnet produce higher quality but take longer — try a faster model if latency is an issue. Groq is particularly fast for cloud inference.
The game handles CORS automatically for OpenAI, OpenAI Compatible, and Anthropic Compatible providers via the relay endpoint. If you're seeing CORS errors, make sure you're using the correct provider type — Gemini and Anthropic work direct from the browser, everything else routes through /api/ai/relay.
These services use the OpenAI Compatible provider. Ensure the endpoint URL is correct and includes /v1. The model name must match exactly what the service expects (e.g., deepseek-chat for DeepSeek, or the full OpenRouter model slug like openai/gpt-4.1).