碳塑复材科技(郑州)有限公司
Section navigation

CCS

Connect Claude Code to 魔方AI with a CCS API profile and its local OpenAI-compatible protocol-conversion proxy.

How the integration works

This guide uses the official CCS OpenAI-Compatible Routing path:

Claude Code
    ↓ Anthropic Messages
Local CCS proxy (127.0.0.1, port selected by CCS)
    ↓ OpenAI Chat Completions
https://www.mofangai001.cn/v1/chat/completions

Use this 魔方AI API Base URL:

https://www.mofangai001.cn/v1

Do not enter the complete /chat/completions request URL or add a second /v1. CCS starts the local proxy, translates the protocol, and forwards the request to 魔方AI.

Prerequisites

Before you begin, make sure that:

  • Node.js 18 or later is installed.
  • Claude Code is installed and claude --version works in your terminal.
  • You have signed in to 魔方AI and created an active token on the Token Management page.
  • You know the exact model IDs allowed by the token. Each ID must match the value shown in 魔方AI.

1. Install CCS

Run this in PowerShell, Windows Terminal, or a macOS/Linux terminal:

npm install -g @kaitranntt/ccs@latest

Verify the installation:

ccs --version

Install CCS and open its dashboard

2. Open API Profiles

Run:

ccs config

CCS opens its local configuration dashboard in your browser. Select API Profiles in the sidebar, then click New or Create Profile.

Open API Profiles in CCS

3. Create the 魔方AI profile

Enter these values under Basic Information:

FieldValue
Profile Namemofang
API Base URLhttps://www.mofangai001.cn/v1
API KeyYour 魔方AI token, for example sk-your-api-key
Default TargetClaude Code

The profile name becomes part of the launch command. Lowercase letters, numbers, and hyphens are recommended.

Enter the 魔方AI profile settings

4. Configure model mappings

Open Model Configuration and enter model IDs allowed by the current 魔方AI token:

FieldPurpose
Default ModelThe default model, for example your-model-id
Opus ModelModel used when Claude Code requests the Opus tier
Sonnet ModelModel used when Claude Code requests the Sonnet tier
Haiku ModelModel used when Claude Code requests the Haiku tier

If you only need one model, use the same exact model ID for all four fields. For separate mappings, verify that every ID is allowed by the token.

Enable the CCS [1m] option only when the selected model and upstream account actually support long context. The option cannot bypass upstream entitlements, quota, or billing requirements.

Save the profile when finished.

Configure 魔方AI model mappings

5. Confirm the OpenAI-compatible provider type

This check is required for 魔方AI. Open the new mofang profile and confirm that the environment variables or Additional Variables contain:

CCS_DROID_PROVIDER=generic-chat-completion-api

This tells CCS that 魔方AI exposes OpenAI Chat Completions and that Claude Code traffic must go through the local protocol-conversion proxy.

If your CCS dashboard does not show this field, edit the profile settings file directly:

  • Windows: %USERPROFILE%\.ccs\mofang.settings.json
  • macOS/Linux: ~/.ccs/mofang.settings.json

The important fields should look like this:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://www.mofangai001.cn/v1",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-api-key",
    "ANTHROPIC_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "your-model-id",
    "CCS_DROID_PROVIDER": "generic-chat-completion-api"
  }
}

Confirm the OpenAI-compatible provider type

6. Launch Claude Code

From the project directory where you want to work, run:

ccs mofang

CCS starts the profile's local OpenAI-compatible proxy and launches Claude Code. The terminal normally prints a message similar to:

Using local OpenAI-compatible proxy for "mofang" on port ...

Check the proxy from another terminal if needed:

ccs proxy status mofang

Send a short test message in Claude Code and confirm that the model returns a response.

Launch the 魔方AI profile

Optional: create the profile in the terminal

Instead of the dashboard, run the interactive wizard:

ccs api create mofang

Enter the following when prompted:

  1. API Base URL: https://www.mofangai001.cn/v1
  2. API Key: your 魔方AI token
  3. Default Model: a model ID allowed by the token
  4. Opus / Sonnet / Haiku mappings: configure as needed
  5. Default Target: choose Claude Code, not Factory Droid

After the wizard completes, still verify CCS_DROID_PROVIDER as described above. Avoid putting the real token in a command-line --api-key argument because it can remain in shell history, process details, or recordings.

Configuration files and security

CCS stores its main configuration under ~/.ccs/. Profile settings files contain the complete 魔方AI token.

  • Do not share *.settings.json, exported profiles, terminal screenshots, or debug logs.
  • Do not commit ~/.ccs/ to Git.
  • Use a dedicated 魔方AI token for CCS so model access, quota, IP rules, and revocation can be managed independently.
  • If a token leaks, disable or delete it in 魔方AI immediately and update the CCS profile.
  • The local CCS proxy binds to 127.0.0.1 by default. Do not expose it to a LAN or the public internet without reliable authentication, firewall rules, and a trusted network.

Troubleshooting

Why must the Base URL include /v1?

This guide uses 魔方AI's OpenAI Chat Completions compatibility API. CCS appends /chat/completions, so https://www.mofangai001.cn/v1 resolves to https://www.mofangai001.cn/v1/chat/completions.

Why do I see a 404 or /v1/v1?

Keep exactly one /v1 in the Base URL. Do not enter the full /v1/chat/completions URL or append another /v1 to an address generated by CCS.

Why did CCS not start the local proxy?

Confirm that CCS_DROID_PROVIDER is generic-chat-completion-api, then run ccs mofang again. Use ccs proxy status mofang to inspect the profile's proxy state.

Why do I receive a 401 or 403?

Confirm that the 魔方AI token is complete, active, unexpired, and has available quota. Also check model permissions, IP allowlists, and other token restrictions.

Why does CCS report that the model does not exist?

Copy an allowed model ID from 魔方AI's Token Management page and enter it exactly. Do not use a display name or an abbreviated model name.

How do I stop the proxy or remove the profile?

Run ccs proxy stop mofang to stop its local proxy. When you no longer need the profile, run ccs api remove mofang and revoke its 魔方AI token.

Official resources