How to Get an AI API Key
Learn how to obtain an API key for Google Gemini, Groq, OpenAI, OpenRouter, or run a free local model with Ollama.
No API Key Required to Play! Offline Ready
Trivia Arena includes a built-in offline deck of 36 verified trivia questions. You can jump in and play immediately without signing up for anything. An API key is only needed if you want unlimited fresh questions or custom categories (e.g., "Marvel Universe", "90s Grunge", "Texas Craft Beers").
📊 Provider Quick Comparison
| Provider | Cost / Free Tier | Speed | Default Model | Console Link |
|---|---|---|---|---|
| Google Gemini Recommended | 100% Free Tier (15 req/min) | Fast (~1.2s) | gemini-1.5-flash | Google AI Studio → |
| Groq Cloud | 100% Free Developer Tier | Blazing (~0.3s) | llama-3.1-8b-instant | Groq Console → |
| OpenAI (ChatGPT) | Pay-As-You-Go (~$0.001/question) | Fast (~1.5s) | gpt-4o-mini | OpenAI Platform → |
| OpenRouter | Free models available & Pay-Go | Varies (~1-2s) | llama-3.1-8b-instruct:free | OpenRouter Keys → |
| Ollama (Local) | 100% Free & No Key | Depends on your PC/GPU | llama3 | Ollama.com → |
Google Gemini (Recommended)
Free tier with generous limits & high trivia accuracy
- Visit Google AI Studio (aistudio.google.com/app/apikey) and log in with any Google account.
- Click the blue button labeled "Create API key".
- Select an existing Google Cloud project or choose "Create API key in new project" (takes about 5 seconds, no credit card required).
-
Copy your newly created key (it starts with
AIzaSy...).
gemini-1.5-flashhttps://generativelanguage.googleapis.com/v1beta/openai/chat/completions
Groq Cloud (Blazing Fast)
Generates trivia questions almost instantly via LPU hardware
- Visit Groq Console (console.groq.com/keys).
- Sign in using your Google or GitHub account.
- Click "Create API Key", enter a label (e.g. "Trivia Arena"), and click Submit.
-
Copy the key immediately (starts with
gsk_...).
llama-3.1-8b-instanthttps://api.groq.com/openai/v1/chat/completions
OpenAI (ChatGPT / GPT-4o-mini)
Industry standard quality and witty explanations
- Log in to OpenAI Platform (platform.openai.com/api-keys).
- Ensure you have a small prepaid credit balance in your account under Settings → Billing (e.g., $5 lasts for hundreds of game rounds).
-
Click "Create new secret key", give it a name, and copy the key (starts with
sk-proj-...).
gpt-4o-minihttps://api.openai.com/v1/chat/completions
Ollama / Local LLM (100% Offline)
Run models privately on your laptop or desktop with zero cloud API keys
- Download and install Ollama from ollama.com.
-
Open your terminal (PowerShell, Command Prompt, or Terminal) and run:
ollama run llama3
-
Ensure CORS is enabled so your browser can communicate with Ollama on localhost. Set environment variable
OLLAMA_ORIGINS="*"before launching Ollama if needed. -
In Trivia Arena, select Ollama / Local LLM. Leave API Key blank or enter
ollama.
llama3http://localhost:11434/v1/chat/completions
⚙️ How to Enter Your API Key in the Game (Super Simple!)
- Open Trivia Arena.
- Click the "⚙️ AI" button in the top navigation bar or the "Configure API Key" button in the setup panel.
-
Paste your key into the API Key box.
✨ Smart Auto-Detection: The arena automatically recognizes Google Gemini keys (starts with
AIzaSy...) and Groq keys (starts withgsk_...), instantly selecting the right provider for you! - Choose your desired model from the Model Dropdown (defaults to Gemini 1.5 Flash (Recommended - Free & Fast)).
- Click 🧪 Test API Connection. You should see a green checkmark confirming connectivity.
- Click Save AI Settings. You're ready to play with live AI trivia generation!
Your API key is stored strictly on your local device inside your browser's localStorage. When you play, the client browser connects directly to the provider's API endpoint (e.g. Google or OpenAI). Your API key is never transmitted to, stored on, or logged by Trinhism servers.