Adding AI to Claude Code using Generative APIs
Claude Code is a coding agent for terminal and IDE. With the help of a proxy like y-router, you can integrate Scaleway's Generative APIs models with Claude Code.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A valid API key for API authentication
- Installed Claude Code on your local machine
Setting up y-router as a proxy
To connect Claude Code to Scaleway's Generative APIs, you will use y-router as a lightweight proxy. y-router is an open-source Cloudflare worker that translates between Anthropic's Claude API and OpenAI-compatible APIs.
Clone and configure y-router
-
Clone the y-router repository:
git clone https://github.com/luohy15/y-router cd y-router -
Edit the
wrangler.tomlfile and add the following configuration:[vars] OPENROUTER_BASE_URL = "https://api.scaleway.ai/v1" -
Start the proxy:
docker compose up -dYou can verify the router is running correctly by performing a query or opening http://localhost:8787/ in your browser. You should see a page displaying
Claude Code + OpenRouter.
Configure Claude Code
-
Verify Claude Code is installed on your local computer:
claude -vThis command should display the Claude Code version:
2.1.1 (Claude Code) -
Add the following environment variables to your
.bashrcfile:export ANTHROPIC_DEFAULT_HAIKU_MODEL=devstral-2-123b-instruct-2512 export ANTHROPIC_SMALL_FAST_MODEL=devstral-2-123b-instruct-2512 export ANTHROPIC_MODEL=devstral-2-123b-instruct-2512 export ANTHROPIC_BASE_URL=http://localhost:8787 export ANTHROPIC_AUTH_TOKEN="<SCW_SECRET_KEY>" export ANTHROPIC_DEFAULT_SONET_MODEL=devstral-2-123b-instruct-2512 -
Reload your shell configuration:
source ~/.bashrc
Using Claude Code with Scaleway's Generative APIs
Once configured, you can start using Claude Code with Scaleway's Generative APIs:
-
Launch Claude Code:
claude -
Select your prefered theme and press
Enter. -
Select whether you trust the files in the current folder.
-
Type any prompt to get started using models running on Scaleway Generative APIs. You can verify configuration is correct by typing
/models. The list of models should display, includingdevstral-2-123b-instruct-2512as defined in environment variables.If you see a message prompting you to log in, displaying
Select login method:orCredit balance too low · Add funds:, ensure you have properly set up environment variables, especiallyANTHROPIC_AUTH_TOKENwith your Scaleway secret key. If you were already logged in with an Anthropic or Claude account, you may need to use/logoutto sign out from the account, as this may conflict with API key authentication defined throughANTHROPIC_AUTH_TOKEN.
Going further
You can customize the proxy settings or explore additional features provided by y-router to optimize your setup further. For more details, refer to the y-router documentation.