Skip to content

Claude Code Integration

This guide shows how to configure Claude Code to use R9S as its API provider.

Before you start, make sure you have:

  1. Claude Code installed

    Follow the official Claude Code quickstart to install and set up Claude Code locally.

  2. An R9S API key

    Sign up on the R9S platform and create an API key.

Edit your Claude Code settings file:

Terminal window
vim ~/.claude/settings.json

Add the following configuration:

{
"env": {
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
"ANTHROPIC_BASE_URL": "https://api.r9s.ai",
"ANTHROPIC_AUTH_TOKEN": "R9S API KEY"
}
}

Replace "R9S API KEY" with your actual API key from R9S.

If your `settings.json` already contains an `env` object, merge these values into the existing object instead of replacing your full configuration file.

Claude Code can select a model through its model setting:

{
"model": "sonnet",
"env": {
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
"ANTHROPIC_BASE_URL": "https://api.r9s.ai",
"ANTHROPIC_AUTH_TOKEN": "R9S API KEY"
}
}

You can also select a model when starting Claude Code:

Terminal window
claude --model sonnet

Or switch models inside an active Claude Code session:

/model sonnet

To expose a custom model option in Claude Code, set ANTHROPIC_CUSTOM_MODEL_OPTION and ANTHROPIC_CUSTOM_MODEL_OPTION_NAME in the env object.

For DeepSeek:

{
"model": "deepseek-v4-pro",
"env": {
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
"ANTHROPIC_BASE_URL": "https://api.r9s.ai",
"ANTHROPIC_AUTH_TOKEN": "R9S API KEY",
"ANTHROPIC_CUSTOM_MODEL_OPTION": "deepseek-v4-pro",
"ANTHROPIC_CUSTOM_MODEL_OPTION_NAME": "DeepSeek via R9S"
}
}

For GLM:

{
"model": "glm-5.1",
"env": {
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
"ANTHROPIC_BASE_URL": "https://api.r9s.ai",
"ANTHROPIC_AUTH_TOKEN": "R9S API KEY",
"ANTHROPIC_CUSTOM_MODEL_OPTION": "glm-5.1",
"ANTHROPIC_CUSTOM_MODEL_OPTION_NAME": "GLM 5.1 via R9S"
}
}
Claude Code sends Anthropic-compatible requests. Custom models such as DeepSeek or GLM require R9S to support the selected model ID through the Claude-compatible route, including any tool-use behavior required by Claude Code.

Claude Code is maintained by Anthropic, and some beta features are only supported by Anthropic’s official service.

R9S currently uses Claude models through AWS Bedrock. Because Bedrock does not fully support certain beta flags, leaving experimental features enabled may cause intermittent 400 errors.

For example:

{
"error": {
"message": "ValidationException: invalid beta flag"
},
"type": "error"
}

Set the following environment variable to avoid sending unsupported beta parameters:

"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"

To use R9S with Claude Code in VS Code:

  1. Install the Claude Code for VS Code extension from the VS Code Marketplace.
  2. Open the extension and start using Claude Code.
  3. The extension reads your local Claude Code configuration, so after ~/.claude/settings.json is configured, requests are routed through the R9S API automatically.