Client Integration Guide
This document provides a detailed configuration guide for integrating third-party clients with EMCP Token, helping you use EMCP Token across various clients.
Integration Preparation
Prerequisites
- Get an API Key: Log in to xftoken.ctclouds.com, go to the Key Management page, and create and copy an API Key.
- Platform access domain: EMCP Token's access domain is
https://api.xftoken.ctclouds.com.
General Configuration Rules
- Domain replacement: replace the OpenAI official domain
https://api.openai.comin the client withhttps://api.xftoken.ctclouds.com. - API Key: fill in your EMCP Token Key in the client's API Key setting.
- Model selection: select a model supported by EMCP Token, such as
claude-sonnet-4-6,gpt-5.4, etc. - Protocol selection: OpenAI clients typically use Chat Completions or Responses; Claude Code uses Anthropic Messages; Gemini CLI uses the Gemini native interface.
CherryStudio Integration
Features
CherryStudio offers the following powerful features:
- ✅ Multi-model support: supports mainstream AI models such as Claude, Gemini, and GPT
- ✅ Unified interface: manage all AI services in one app
- ✅ Custom API: supports connecting custom API providers
- ✅ Cross-platform: supports Windows, macOS, Linux
- ✅ Local-first: data stored locally for privacy protection
- ✅ Rich features: conversation management, model switching, parameter tuning, and more
Installation Steps
Download and install CherryStudio
- Visit the CherryStudio official website
- Choose the installer for your OS:
- Windows: download the .exe installer
- macOS: download the .dmg image
- Linux: download the .AppImage or .deb package
- After downloading, complete the installation following the system prompts
Note for macOS users: if you see "cannot be opened because it is from an unidentified developer", allow it in System Preferences → Security & Privacy.
Configure the Claude Model
Open the Settings page
- Open the CherryStudio app
- Click Settings or Preferences at the bottom-left
- Select Model Configuration or API Configuration
Select the Claude model type
- Choose the Claude model you need from the model list:
- Claude Sonnet 4.5: claude-sonnet-4-5-20250929 — latest version, suitable for daily coding and conversation (recommended)
- Claude Opus 4.5: claude-opus-4-5-20251101 — best performance, suitable for complex tasks
- Claude 3.5 Haiku: fast, suitable for simple tasks
- Choose the Claude model you need from the model list:
Configure the Claude API
- Fill in the following in the Claude configuration screen:
- Provider type: select Anthropic
- API Address:
https://api.xftoken.ctclouds.com/v1/messages - API Key: paste your EMCP Token Key
- Model name: enter the selected model name (e.g., claude-sonnet-4-5-20250929)
- Fill in the following in the Claude configuration screen:
Configure the Gemini Model
Select the Gemini model type
- Choose the Gemini model you need from the model list:
- Gemini 3 Flash Preview: gemini-3-flash-preview — latest version, fast and high-performing (recommended)
- Gemini 3 Pro Preview: gemini-3.1-pro-preview — high performance, suitable for complex tasks
- Gemini 2.0 Flash: fast response, suitable for simple conversations
- Choose the Gemini model you need from the model list:
Configure the Gemini API
- Fill in the following in the Gemini configuration screen:
- Provider type: select Gemini
- API Address:
https://api.xftoken.ctclouds.com/v1beta/models - API Key: paste your EMCP Token Key
- Model name: enter the selected model name (e.g., gemini-3-flash-preview)
- Fill in the following in the Gemini configuration screen:
Getting Started
Create a new conversation
- Click the New Chat button
- Select the configured model in the model selector
- Start chatting with the AI
Switch models
- During a conversation, click the model selector at the top
- Select another configured model
- Continue the conversation (context may be preserved or reset depending on app settings)
Adjust parameters
- CherryStudio supports adjusting the following parameters:
- Temperature: controls response randomness (0–1)
- Max Tokens: controls response length
- Top P: controls the sampling range
Parameter suggestions:
- Coding tasks: Temperature 0.2–0.5 (more accurate)
- Creative writing: Temperature 0.7–0.9 (more creative)
- Daily conversation: Temperature 0.5–0.7 (balanced)
- CherryStudio supports adjusting the following parameters:
Best Practices
Choose models wisely
- Code writing: Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
- Quick conversation: Gemini 3 Flash Preview (gemini-3-flash-preview)
- Complex reasoning: Claude Opus 4.5 (claude-opus-4-5-20251101)
- Multimodal tasks: Gemini 3 Pro Preview (supports images)
Manage API usage
- Check your account balance regularly
- Create different API Keys for different purposes
- Avoid exposing your API Key in public
Optimize the conversation experience
- Use clear prompts
- Set a reasonable context length
- Make good use of conversation history management
OpenClaw Integration
Features
OpenClaw is a feature-rich AI coding agent tool with the following characteristics:
- ✅ Terminal TUI: command-line interactive interface, suitable for SSH environments
- ✅ Web Dashboard: browser-based visual management panel
- ✅ Telegram Bot: supports remote conversation via Telegram
- ✅ Multi-model support: various models such as Claude, GPT, Gemini
- ✅ Gateway: built-in gateway service with reverse proxy support
- ✅ Skill extensions: install extension skills via the Dashboard
Installation and Initialization
Run the install script
- Log in via SSH to the server or run the following command in the macOS terminal:
curl -fsSL https://openclaw.ai/install.sh | bash - Wait patiently for the installation to finish
- Log in via SSH to the server or run the following command in the macOS terminal:
Initialize configuration
- During installation you will see the following options in sequence; follow the instructions:
- Launch mode: select QuickStart (quick start mode)
- Provider settings: select Skip for now (edit the config file manually later)
- Adapter selection: select anthropic
- Model selection: select opus-4.5 or another model you need
- Social adapter: select as needed (e.g., Telegram, optional)
- Skill installation: skip (install later via Dashboard)
- Hook selection: select all (use the spacebar to select all, then press Enter to confirm)
- Open mode: skip (skip for now)
- Shell completion: yes (install command-line auto-completion)
- During installation you will see the following options in sequence; follow the instructions:
Channel and Model Configuration
Edit the configuration file
- Open the OpenClaw configuration file for editing:
vim ~/.openclaw/openclaw.json
- Open the OpenClaw configuration file for editing:
Configure provider information
- Configure EMCP Token information under
models.providers. Example configuration:"models": { "providers": { "emcp-token": { "baseUrl": "https://api.xftoken.ctclouds.com/v1", "apiKey": "YOUR_SMART_API_KEY", "api": "openai-completions", "headers": { "User-Agent": "claude-cli/2.0.76 (external, cli)", "Authorization": "Bearer YOUR_SMART_API_KEY" }, "models": [ { "id": "gpt-5.4", "name": "gpt-5.4", "contextWindow": 128000, "maxTokens": 32000 }, { "id": "claude-opus-4-6", "name": "claude-opus-4-6", "contextWindow": 200000, "maxTokens": 4096 } ] } } }
Important notes:
- You must add the
headersfield, otherwise the request will be blocked and return 403 - The value of
Authorizationmust matchapiKey, in the formatBearer YOUR_SMART_API_KEY - The
User-Agentmust keep the format shown in the example; do not omit or arbitrarily modify it
- Configure EMCP Token information under
Restart the gateway
openclaw gateway restartVerify the configuration
- Run the following command to enter the TUI and test whether the model works normally:
openclaw tui - After a successful test, enter
/quitto exit the TUI
- Run the following command to enter the TUI and test whether the model works normally:
Access the Dashboard via Browser
Get the Dashboard URL
- Run a command in the console to get the Dashboard URL, then open it in a browser to enter the management panel
Notes for server users
- If you run OpenClaw on a remote server, you need to:
- Configure a reverse proxy: use Nginx or another reverse proxy tool to proxy the OpenClaw service and set up an SSL certificate
- Edit the configuration file: edit
~/.openclaw/openclaw.jsonand add under the gateway field:"controlUi": { "allowInsecureAuth": true } - Restart the gateway:
openclaw gateway restart
- Access the Dashboard URL with the token to enter the admin interface
- If you run OpenClaw on a remote server, you need to:
FAQ
Getting "403 Your request was blocked"?
- Solution: add the
headersfield in the provider configuration and ensureUser-AgentandAuthorizationare set correctly
Cannot connect to the API
- Solution:
- Check whether
baseUrlin the configuration file is correct - Confirm whether
apiKeyis valid - Check whether the network connection is normal
- Verify whether the
headersconfiguration is correct
- Check whether
Poor model response quality
- Solution:
- Select a model better suited to the task
- Provide more detailed instructions
- Check whether the account balance is sufficient
Claude Code Integration
First-Time Installation Notes
When integrating Claude Code with EMCP Token, the following error may appear on first launch:
Welcome to Claude Code
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_BAD_REQUEST
This is because Claude Code attempts to connect to the official API for initialization confirmation on first launch. You need to manually modify the configuration file first:
- Locate the
~/.claude.jsonfile in the user home directory - Add the
"hasCompletedOnboarding": truefield at the end (mind the JSON format — add a comma after the previous field before adding this one):
{
"installMethod": "unknown",
"autoUpdates": true,
"firstStartTime": "2025-07-14T06:11:03.877Z",
"userID": "xxxx",
"projects": {
"/home/your-user": {
"allowedTools": [],
"history": [],
"mcpContextUris": [],
"mcpServers": {},
"enabledMcpjsonServers": [],
"disabledMcpjsonServers": [],
"hasTrustDialogAccepted": false,
"projectOnboardingSeenCount": 0,
"hasClaudeMdExternalIncludesApproved": false,
"hasClaudeMdExternalIncludesWarningShown": false
}
},
"hasCompletedOnboarding": true // add this field
}
- After saving the changes, re-run Claude Code to use it normally
Installation Method
Windows
Try the Native Install method:
- Using PowerShell:
irm https://claude.ai/install.ps1 | iex - Using CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Verify the installation:
claude --version
macOS
Method 1: Homebrew (recommended)
brew install --cask claude-code
Method 2: Curl Script
curl -fsSL https://claude.ai/install.sh | bash
Verify the installation
claude -v
Environment Variable Configuration
Windows
PowerShell:
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "YOUR_SMART_API_KEY", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.xftoken.ctclouds.com", "User")
CMD:
setx ANTHROPIC_AUTH_TOKEN "YOUR_SMART_API_KEY"
setx ANTHROPIC_BASE_URL "https://api.xftoken.ctclouds.com"
macOS
Add the following to your ~/.bashrc or ~/.zshrc file:
export ANTHROPIC_AUTH_TOKEN="YOUR_SMART_API_KEY"
export ANTHROPIC_BASE_URL="https://api.xftoken.ctclouds.com"
Then run:
source ~/.bashrc # or source ~/.zshrc
Configuration Verification
After setting the environment variables, restart the terminal to apply them.
Launch and Usage
In the terminal, navigate to a project directory or enter the command in any directory:
claudeClaude Code starts and connects to EMCP Token
Start using Claude Code for code generation, analysis, and debugging
FAQ
1. Error on first launch
Solution:
- Modify the configuration file as described in "First-Time Installation Notes" to skip initialization confirmation
2. Cannot connect to the API
Solution:
- Check whether the environment variables are set correctly
- Confirm whether the EMCP Token Key is valid
- Check whether the network connection is normal
3. Poor model response quality
Solution:
- Make sure you are using the correct model (e.g.,
claude-opus-4-6) - Provide more detailed instructions and context
- Check whether the account balance is sufficient
Best Practices
Environment variable management:
- Store the API Key in an environment variable to avoid hardcoding it in code
- Rotate the API Key regularly to improve security
Model selection:
- Complex code generation: use
gpt-5.4orclaude-opus-4-6 - Code analysis and debugging: use
claude-sonnet-4-6orgemini-3.1-pro-preview
- Complex code generation: use
Instruction optimization:
- Clearly state the purpose and requirements of the code
- Provide relevant context information
- Indicate the expected output format
Configuration backup:
- Regularly back up the
~/.claude.jsonconfiguration file - Record important environment variable settings
- Regularly back up the
CodeX Integration
Features
CodeX is a next-generation intelligent coding assistant built on the GPT-5 architecture, providing developers with excellent code generation and optimization capabilities.
Installation Steps
Deploy the CodeX CLI tool
- Launch Command Prompt or PowerShell as administrator and run:
npm install -g @openai/codex@latest codex --version
- Launch Command Prompt or PowerShell as administrator and run:
Get EMCP Token credentials
- Log in to xftoken.ctclouds.com
- Go to the Key Management page
- Create a new API Key
Manual Command-Line Configuration
Windows
Build the config directory structure
mkdir %USERPROFILE%\.codex cd %USERPROFILE%\.codexWrite the configuration files
config.toml
model_provider = "EMCP Token" model = "gpt-5.4" model_reasoning_effort = "xhigh" disable_response_storage = true approval_policy = "on-request" sandbox_mode = "danger-full-access" model_supports_reasoning_summaries = true [model_providers.EMCPToken] name = "EMCP Token" base_url = "https://api.xftoken.ctclouds.com/v1" wire_api = "responses" requires_openai_auth = trueauth.json
{ "OPENAI_API_KEY": "Paste your EMCP Token Key here" }
Initialize the workspace
mkdir my-codex-project cd my-codex-project codex
macOS
Deploy the CodeX tool
npm install -g @openai/codex@latest codex --versionBuild the config directory
mkdir -p ~/.codex cd ~/.codexWrite the configuration files
config.toml
cat > config.toml << 'EOF' model_provider = "EMCP Token" model = "gpt-5.4" model_reasoning_effort = "xhigh" disable_response_storage = true approval_policy = "on-request" sandbox_mode = "danger-full-access" model_supports_reasoning_summaries = true [model_providers.EMCPToken] name = "EMCP Token" base_url = "https://api.xftoken.ctclouds.com/v1" wire_api = "responses" requires_openai_auth = true EOFauth.json
cat > auth.json << 'EOF' { "OPENAI_API_KEY": "Paste your EMCP Token Key here" } EOF
Initialize the workspace
mkdir my-codex-project cd my-codex-project codex
Linux
Deploy the CodeX tool
sudo npm install -g @openai/codex@latest codex --versionBuild the config directory
mkdir -p ~/.codex cd ~/.codexWrite the configuration files
config.toml
cat > config.toml << 'EOF' model_provider = "EMCP Token" model = "gpt-5.4" model_reasoning_effort = "xhigh" disable_response_storage = true approval_policy = "on-request" sandbox_mode = "danger-full-access" model_supports_reasoning_summaries = true [model_providers.EMCPToken] name = "EMCP Token" base_url = "https://api.xftoken.ctclouds.com/v1" wire_api = "responses" requires_openai_auth = true EOFauth.json
cat > auth.json << 'EOF' { "OPENAI_API_KEY": "Paste your EMCP Token Key here" } EOF
Initialize the workspace
mkdir my-codex-project cd my-codex-project codex
Getting Started
Code generation
- In the workspace, type a natural-language description of the code you need
- CodeX generates the corresponding code based on the description
Code completion
- Start writing code and CodeX automatically provides completion suggestions
- Press Tab to accept a suggestion
Code analysis
- Paste existing code and enter an analysis request
- CodeX analyzes the code and provides improvement suggestions
FAQ
Cannot connect to the API
- Solution:
- Check whether
base_urlin the configuration file is correct - Confirm whether
OPENAI_API_KEYis valid - Check whether the network connection is normal
- Check whether
Poor code generation quality
- Solution:
- Provide more detailed instructions and context
- Select a more suitable model (e.g.,
gpt-5.4) - Check whether the account balance is sufficient
Configuration file error
- Solution:
- Ensure
config.tomlandauth.jsonare correctly formatted - Verify the file paths are correct
- Restart the CodeX app
- Ensure
Gemini CLI Integration
Features
Gemini CLI is Google's AI coding assistant, powered by Gemini 2.5 Pro, providing intelligent code generation and analysis capabilities.
Installation Steps
Windows
Install Gemini CLI globally
npm install -g @google/gemini-cliConfigure Gemini CLI
- Create the config directory: create the
%USERPROFILE%\.gemini\folder in your user directory - Create the .env file:
GOOGLE_GEMINI_BASE_URL=https://api.xftoken.ctclouds.com GEMINI_API_KEY=Your EMCP Token Key GEMINI_MODEL=gemini-3.1-pro-preview - Create the settings.json file:
{ "ide": { "enabled": true }, "security": { "auth": { "selectedType": "gemini-api-key" } } }
- Create the config directory: create the
Launch Gemini CLI
gemini
macOS
Install Gemini CLI globally
npm install -g @google/gemini-cliConfigure Gemini CLI
- Create the config directory:
mkdir -p ~/.gemini cd ~/.gemini - Create the .env file:
cat > .env << 'EOF' GOOGLE_GEMINI_BASE_URL=https://api.xftoken.ctclouds.com GEMINI_API_KEY=Your EMCP Token Key GEMINI_MODEL=gemini-3.1-pro-preview EOF - Create the settings.json file:
cat > settings.json << 'EOF' { "ide": { "enabled": true }, "security": { "auth": { "selectedType": "gemini-api-key" } } } EOF
- Create the config directory:
Launch Gemini CLI
gemini
Linux
Install Gemini CLI globally
sudo npm install -g @google/gemini-cliConfigure Gemini CLI
- Create the config directory:
mkdir -p ~/.gemini cd ~/.gemini - Create the .env file:
cat > .env << 'EOF' GOOGLE_GEMINI_BASE_URL=https://api.xftoken.ctclouds.com GEMINI_API_KEY=Your EMCP Token Key GEMINI_MODEL=gemini-3.1-pro-preview EOF - Create the settings.json file:
cat > settings.json << 'EOF' { "ide": { "enabled": true }, "security": { "auth": { "selectedType": "gemini-api-key" } } } EOF
- Create the config directory:
Launch Gemini CLI
gemini
Getting Started
Send a text request
gemini chat "Hello, EMCP Token!"Generate code
gemini code "Write a Python function to calculate Fibonacci numbers"Analyze a file
gemini analyze ./example.jsAgent Mode (automated coding)
- Enter a context description and Gemini CLI will automatically generate and execute code
Google Search (real-time web search)
- Gemini CLI can fetch the latest information via web search
FAQ
Where do I get the API Key?
- Log in to xftoken.ctclouds.com and create an EMCP Token Key
Config file location
- Windows:
%USERPROFILE%\.gemini\ - macOS/Linux:
~/.gemini/
Cannot connect to the API
- Solution:
- Check whether
GOOGLE_GEMINI_BASE_URLin the.envfile is correct - Confirm whether
GEMINI_API_KEYis valid - Check whether the network connection is normal
- Check whether
Poor model response quality
- Solution:
- Make sure you are using a suitable model (e.g.,
gemini-3.1-pro-preview) - Provide more detailed instructions and context
- Check whether the account balance is sufficient
- Make sure you are using a suitable model (e.g.,
OpenCode Integration
Features
OpenCode is an open-source AI coding assistant with the following characteristics:
- ✅ Native terminal TUI: designed for command-line developers, efficient and smooth
- ✅ Smart LSP loading: automatically loads the correct language server to improve context understanding
- ✅ Multi-session parallelism: multiple sessions can run simultaneously without interference
- ✅ Session link sharing: share session links with others for collaboration
- ✅ 75+ model support: supports many model providers, including local models
- ✅ Multi-platform support: terminal CLI, desktop app (Beta), IDE extensions
Installation and Configuration
Install OpenCode
- Open a terminal and run the following command to install OpenCode globally:
npm install -g opencode-ai - After installation, type the
opencodecommand in the terminal; if the TUI appears, the installation succeeded
- Open a terminal and run the following command to install OpenCode globally:
Install CC-Switch
- Download and install the CC-Switch configuration tool
Add the EMCP Token provider
- Open CC-Switch, select OpenCode in the top configuration item, then click the Add Provider button
- Fill in the provider information:
- Preset provider: select EMCP Token
- Provider ID: a custom name, e.g., EMCP Token
- Interface format:
- Claude models select Anthropic
- GPT models select OpenAI
- Gemini models select Google (Gemini)
- API Key: enter the Key you created in the EMCP Token console
- Extra options: enter
{"setCacheKey":true}
Verify the Configuration
- Reopen the terminal and run
opencode - Enter the
/modelscommand and check whether the configured channel appears in the model list - If you can see the model you added, the configuration is successful
- Start using OpenCode for coding
Getting Started
Create a new session
- Run the
opencodecommand - Enter the
/newcommand to create a new session - Select your configured EMCP Token model
- Run the
Code generation
- Enter a natural-language description of the code you need
- OpenCode generates the corresponding code based on the description
Code analysis
- Paste existing code
- Enter an analysis request
- OpenCode analyzes the code and provides improvement suggestions
Multi-session management
- Enter
/listto view all sessions - Enter
/switch <session ID>to switch to a specified session - Enter
/shareto generate a session share link
- Enter
FAQ
npm not found during installation?
- Solution: install the Node.js environment first
Configured channel not visible in the model list?
- Solution:
- Confirm the configuration is saved correctly in CC-Switch
- Restart the terminal and run opencode again
- Check whether the API Key is filled in correctly
Cannot connect to the API
- Solution:
- Check whether the API Key in CC-Switch is correct
- Confirm whether the EMCP Token service is running normally
- Check whether the network connection is normal
Poor code generation quality
- Solution:
- Select a model better suited to code generation (e.g.,
gpt-5.4) - Provide more detailed instructions and context
- Check whether the account balance is sufficient
- Select a model better suited to code generation (e.g.,
Best Practices
Model selection
- Complex code generation: use
gpt-5.4orclaude-opus-4-6 - Code analysis: use
claude-sonnet-4-6orgemini-3.1-pro-preview - Quick prototyping: use
claude-haiku-4-5-20251001orgemini-3-flash-preview
- Complex code generation: use
Session management
- Create different sessions for different projects
- Use the session sharing feature to collaborate with your team
- Clean up unnecessary sessions regularly to save resources
Instruction optimization
- Clearly state the purpose and requirements of the code
- Provide relevant context information
- Indicate the expected output format
Security management
- Avoid sharing sensitive information in sessions
- Rotate the API Key regularly
- Set reasonable API usage limits
Common Questions and Solutions
Client cannot connect
- Check the network connection: ensure the network connection is normal
- Check the API Key: ensure the API Key is correct and not expired
- Check the domain configuration: ensure the domain is configured correctly, using
https://api.xftoken.ctclouds.com
Model fails to load
- Check API Key permissions: ensure the API Key has sufficient permissions
- Check model availability: ensure the selected model is available in EMCP Token
- Check the network connection: ensure the network connection is normal
Call failed
- Check the API Key: ensure the API Key is correct and not expired
- Check request parameters: ensure the request parameters meet EMCP Token's requirements
- Check model permissions: ensure you have permission to use the selected model
- Check the account balance: ensure the account has sufficient balance