Aider
Track usage, control costs, and add guardrails to your Aider coding sessions
What is Aider?
Aider is an AI pair programming tool that runs in your terminal. It edits code in your local git repository, makes commits, and works across multiple files—driven entirely by natural-language instructions. It connects to any OpenAI-compatible endpoint.
By routing Aider through FastRouter, you get:
100+ models from OpenAI, Anthropic, Google, xAI, Meta, Groq, Mistral, and more through one endpoint—including coding models like Grok Code Fast 1
Observability for every request: cost, tokens, latency, and model selection tracked in real time
Reliability through automatic failover across providers, response caching, and intelligent routing
Governance with per-key budgets, rate limits, model restrictions, role-based access, and project isolation
This guide covers configuring Aider to use FastRouter through its OpenAI-compatible settings.
Prerequisites
A FastRouter.ai account (sign up)
Python 3.10 or higher, and a git repository to work in
Quick Start
Step 1: Install Aider
python -m pip install aider-install
aider-installStep 2: Get Your FastRouter API Key
Sign up or log in at fastrouter.ai
Navigate to your project's Keys page
Click Create User Key
Copy the key immediately. FastRouter does not display the key again after creation.
Step 3: Point Aider at FastRouter
Aider uses LiteLLM under the hood. Set FastRouter as the OpenAI-compatible endpoint with two environment variables. Run these in your terminal—not at Aider's > prompt—before launching Aider:
Note: Environment variables only last for the current terminal session. For a setup that persists, see Persisting your credentials below.
Step 4: Launch Aider with a FastRouter Model
Prefix the FastRouter model slug with openai/ so LiteLLM uses the OpenAI-compatible protocol:
Note: The
openai/prefix is required. It selects the OpenAI-compatible protocol; the rest (x-ai/grok-code-fast-1) is the FastRouter model slug. Without it, LiteLLM cannot determine the provider and fails withLLM Provider NOT provided. For an Anthropic model, use--model openai/anthropic/claude-4.5-sonnet.
If the folder isn't a git repository, Aider offers to create one—answer Yes (recommended, so it can track and undo changes), or run with --no-git to skip git entirely.
On first launch you'll see two harmless warnings: "Unknown context window size and costs" and "Did you mean …". Both occur because Aider's local model database doesn't recognize FastRouter slugs. They don't affect anything—silence them with --no-show-model-warnings.
Aider starts in your repo and is ready for instructions. All requests route through FastRouter, and every request, token count, and cost appears in your FastRouter Dashboard.
Persisting your credentials
Because export only lasts for the current terminal session, the recommended setup is a .env file in your project root, which Aider loads automatically:
With .env in place, just run aider --model openai/x-ai/grok-code-fast-1—no exports needed. Alternatively, add the two export lines to your shell profile (~/.zshrc or ~/.bashrc) to apply them everywhere.
Security: If you use a
.envfile, make sure it is git-ignored (the command above does this). Aider auto-ignores.aider*but not.env.

Use Aider with 100+ Models
FastRouter uses the provider/model-name format (after LiteLLM's openai/ protocol prefix). Switch models with the --model flag:
Recommended models for Aider:
x-ai/grok-code-fast-1— fast and inexpensive; a good default for routine editsanthropic/claude-4.5-sonnet— highest quality for complex, multi-file changesopenai/gpt-5.2— strong all-round alternative
A common Aider pattern is a strong "architect" model for planning plus a cheaper "editor" model for the mechanical edits. Both use the same FastRouter key:
For large files, add --edit-format diff so Aider sends only the changed lines instead of rewriting whole files.
Explore the full model catalog
Automatic Model Selection
Let FastRouter pick the best model for each request based on query complexity, domain, and cost:
Explore automatic model selection
FAQs
Configuration & Setup
I get litellm.AuthenticationError: ... OPENAI_API_KEY ... must be set. What's wrong?
The environment variables aren't set in the terminal you launched Aider from—usually because you opened a new terminal (variables don't persist across sessions) or typed the export lines at Aider's > prompt instead of in the shell. Run the two export commands in your terminal before launching Aider, confirm with echo $OPENAI_API_KEY, or use the .env file so the key is always available.
I get litellm.BadRequestError: LLM Provider NOT provided. What's wrong?
You omitted the openai/ protocol prefix. The model must be openai/<fastrouter-slug>—for example, openai/x-ai/grok-code-fast-1, not x-ai/grok-code-fast-1.
Aider reports an unknown model or context-window warning. Is that a problem?
No. Aider's local model database doesn't have metadata for FastRouter slugs, so it shows "Unknown context window size and costs" and "Did you mean …" and falls back to sane defaults. Everything works—suppress the warnings with --no-show-model-warnings.
Can I use multiple models with the same API key?
Yes. The API key controls access and budget. Switch models with --model at any time—no key changes needed.
Can I restrict a key to only use specific models?
Yes. When creating or editing a key, use the Select Models setting to limit which models the key can access. FastRouter rejects requests to unauthorized models.
Costs & Budgeting
Aider can send large repo context. How do I control cost?
Set a budget and rate limit on the key, and use Aider's /tokens command to monitor context size. The Dashboard breaks down costs by project, key, model, and tag.
Privacy & Security
Is my code sent to FastRouter's servers?
FastRouter acts as a pass-through gateway. Requests are routed to the model provider and responses are returned to your client. Content logging can be disabled per key for sensitive workloads. See the Disable Content Logging option in key settings.
Next Steps
Set up Fallback Models for high availability
Configure Alerts for spend and performance monitoring
Run a Free Audit on your existing LLM traffic to identify savings
Last updated
