Skip to main content

Claude Code

Claude Code is Anthropic's AI programming assistant. This guide walks you through integrating MoArk so you can connect to different model providers while keeping full control over how Claude Code interacts with them. With this setup you stay current with Anthropic updates and retain flexibility over the model workflow.

Configuration Guide

Serverless API supports calling in Claude Code. The steps are as follows:

  1. Install Claude Code and Integration Tools

First, ensure that you have installed Claude Code in your development environment:

npm install -g @anthropic-ai/claude-code

Then, install Claude Code Router as the integration tool:

npm install -g @musistudio/claude-code-router
  1. Get MoArk Access Token

Go to Workbench->Settings->Access Tokens to create an access token. If you have not purchased a Serverless API package yet, you can start with the free trial token (daily call limits apply) for testing.

  1. Configure Integration File

Create a configuration file ~/.claude-code-router/config.json in your home directory and replace your-api-key with your access token:

config.json
 {
"Providers": [
{
"name": "gitee",
"api_base_url": "https://ai.gitee.com/v1/chat/completions",
"api_key": "your-api-key",
"models": ["kimi-k2-instruct"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 131072
}
]
]
}
}
],
"Router": {
"default": "gitee,kimi-k2-instruct",
"background": "gitee,kimi-k2-instruct",
"think": "gitee,kimi-k2-instruct",
"longContext": "gitee,kimi-k2-instruct"
},
"APIKEY": "your-secret-key",
"LOG": true,
"HOST": "0.0.0.0"
}
  1. Start Integration Service

Start Claude Code through our integration solution:

ccr code

  1. Use MoArk in Claude Code

At this point, developers can call models from MoArk in Claude Code. You can also switch models in real-time during development:

/model gitee,kimi-k2-instruct

Configuration Parameters

  • APIKEY (optional): Set the key to verify requests
  • PROXY_URL (optional): Set the proxy for API requests
  • LOG (optional): Enable logging, the log file will be located at $HOME/.claude-code-router.log
  • HOST (optional): Set the host address of the server

Intelligent Routing Configuration

Routing configuration defines the models used in different scenarios:

  • default: Default model, used for all requests if no other routes are configured
  • background: Model used for background tasks
  • think: Model used for thinking tasks
  • longContext: Model used for long context tasks

More Resources