Skip to navigationSkip to main contentSkip to footerScaleway DocsAsk our AI
Ask our AI

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:

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

  1. Clone the y-router repository:

    git clone https://github.com/luohy15/y-router
    cd y-router
  2. Edit the wrangler.toml file and add the following configuration:

    [vars]
    OPENROUTER_BASE_URL = "https://api.scaleway.ai/v1"
  3. Start the proxy:

    docker compose up -d

    You 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

  1. Verify Claude Code is installed on your local computer:

    claude -v

    This command should display the Claude Code version:

    2.1.1 (Claude Code)
  2. Add the following environment variables to your .bashrc file:

    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
  3. 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:

  1. Launch Claude Code:

    claude
  2. Select your prefered theme and press Enter.

  3. Select whether you trust the files in the current folder.

  4. 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, including devstral-2-123b-instruct-2512 as defined in environment variables.

    If you see a message prompting you to log in, displaying Select login method: or Credit balance too low · Add funds:, ensure you have properly set up environment variables, especially ANTHROPIC_AUTH_TOKEN with your Scaleway secret key. If you were already logged in with an Anthropic or Claude account, you may need to use /logout to sign out from the account, as this may conflict with API key authentication defined through ANTHROPIC_AUTH_TOKEN.

Tip

Ensure that the y-router proxy is running in the background whenever you use Claude Code to maintain the connection to Scaleway's Generative APIs.

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.

Note

If you encounter issues with the proxy or API access, verify that your environment variables are correctly set and that the proxy is running without errors.

Still need help?

Create a support ticket
No Results