Pointing Claude Code at the Aggregator for a Single Project: A Minimal project-level Config Walkthrough
Learn how to configure Claude Code to use an LLM API aggregator for a single project. This guide walks through setting the necessary environment variables at the project level, so you can route requests through the aggregator without affecting your global configuration. It also covers prerequisites and verification steps.
Why Use a Project-Level Config?
When working with Claude Code, you might want to use a different API endpoint for a specific project—for example, to route requests through an aggregator that provides access to multiple models with a single API key. A project-level configuration keeps your global settings untouched and ensures that only the current project uses the aggregator.
Prerequisites
Before you begin, make sure you have:
- An API key from the aggregator (you can obtain one by topping up with USDC on Base; no KYC required).
- Claude Code installed and working on your system.
- Basic familiarity with environment variables and your shell.
Step 1: Locate Your Project
Open a terminal and navigate to the root directory of your project. This is where you will create the configuration files.
Step 2: Set Environment Variables Locally
Claude Code reads certain environment variables to determine which API endpoint and key to use. To override these for a single project, you can set them in a .env file or directly in your shell session before running Claude Code.
The relevant variables typically include:
ANTHROPICAPIKEY(or the equivalent for your Claude Code version)ANTHROPICBASEURL(to point to the aggregator's endpoint)
Create a file named .env in your project root (if it doesn't exist) and add the following lines, replacing the placeholders with your actual values:
ANTHROPIC_API_KEY=your_aggregator_api_key_here
ANTHROPIC_BASE_URL=https://api.your-aggregator.com/v1
Alternatively, you can export these variables in your shell before starting Claude Code:
export ANTHROPIC_API_KEY=your_aggregator_api_key_here
export ANTHROPIC_BASE_URL=https://api.your-aggregator.com/v1
Note: The exact variable names may vary depending on your Claude Code version. Check the official documentation for the most up-to-date information.
Step 3: Load the Environment Variables
If you used a .env file, you need to load it into your shell session. You can use a tool like dotenv or simply source the file:
set -a; source .env; set +a
This ensures the variables are available to Claude Code when you run it.
Step 4: Run Claude Code
With the environment variables set, start Claude Code as you normally would. It should now use the aggregator's endpoint and your API key for this session.
Step 5: Verify the Configuration
To confirm that requests are going through the aggregator, you can check the aggregator's dashboard or logs (if available) for incoming requests. Alternatively, you can run a simple test command in Claude Code and observe whether it responds as expected.
Keeping It Project-Specific
By setting these variables only in your project's environment, you avoid affecting other projects or your global Claude Code setup. If you need to switch back to the default configuration, simply open a new terminal session or unset the variables.
Pricing Reminder
When using the aggregator, you pay the official price multiplied by 1.3. If you contribute keys to the aggregator, you are credited the official price multiplied by 1.1 (or 1.2 for premium keys) in USDC. This model ensures transparent, pay-as-you-go access to multiple models without subscriptions.
Conclusion
Configuring Claude Code to use an aggregator for a single project is straightforward: set the API key and base URL as environment variables in your project, load them, and run Claude Code. This approach gives you flexibility while keeping your global settings clean.