CCAPI
Home
Home
  1. OpenClaw Integration
  • OpenClaw Integration
    • OpenClaw + CCAPI LLM Integration Guide
      POST
  • Chat
    • Anthropic
      • Create Chat Completion
    • Google
      • Create Chat Completion
    • OpenAI
      • Create Chat Completion
    • DeepSeek
      • Create Chat Completion
    • MiniMax
      • Create Chat Completion
    • Moonshot
      • Create Chat Completion
    • Qwen
      • Create Chat Completion
    • Zhipu AI
      • Create Chat Completion
  • Video
    • Seedance 2.0(soon)
      • Create Video Job
      • Poll Video Job
    • Veo 3.1
      • Create Video Job
      • Poll Video Job
    • Sora 2
      • Create Video Job
      • Poll Video Job
      • Create Character
      • Poll Character Job
    • Kling 3.0
      • Create Video Job
      • Poll Video Job
    • Midjourney
      • Submit Video Generation or Extend
      • Poll Video Job
      • Submit Video Generation or Extend
      • Poll Video Job
  • Image
    • Midjourney
      • Submit Image Generation or Edit
      • Poll Image Job
    • Gemini Image
      • Generate Image
      • Get Job Status
    • Seedream
      • Generate Image
      • Get Job Status
  • Audio
    • Producer
      • Generate Music
      • Generate Lyrics
      • Extend Music
      • Create Cover
      • Create Variation
      • Replace Segment
      • Vocals Swap
      • Instrumentals Swap
      • Stem Separation
      • Download Audio
      • Upload Audio
      • Generate Video
      • Poll Job Status
    • Suno
      • Generate Music
      • Poll Job Status
      • Generate Lyrics
      • Extend Music
      • Create Cover
      • Extract Stems
      • Extract All Stems
      • Add Vocals
      • Add Instrumental
      • Replace Section
      • Remaster Song
      • Mashup
      • Sample Section
      • Generate Sounds
      • Generate MIDI
      • Upload Audio
      • Concatenate Music
      • Get Aligned Lyrics
      • Generate Music Video
      • Export as WAV
      • Create Voice Persona
      • Detect BPM
      • Extract Vocals
      • Upsample Tags
Home
Home
  1. OpenClaw Integration

OpenClaw + CCAPI LLM Integration Guide

POST
/api/v1/chat/completions

How to Integrate CCAPI LLM into OpenClaw#

This guide walks you through connecting OpenClaw to CCAPI step-by-step. CCAPI is a fully OpenAI-compatible API gateway — OpenClaw treats it as a standard OpenAI endpoint, so no code changes are needed.

Prerequisites#

1.
OpenClaw installed — any version that supports custom LLM providers
2.
CCAPI account — sign up at ccapi.ai/dashboard (free, includes $0.50 credit)
3.
CCAPI API key — create one in Dashboard > API Keys

Step 1: Get Your CCAPI API Key#

1.
Go to ccapi.ai/dashboard and sign up / log in
2.
Navigate to API Keys page (left sidebar > API Keys)
3.
Click Create New Key, give it a name like openclaw
4.
Copy the key immediately — it is only shown once. The key starts with sk-
5.
New accounts automatically receive $0.50 free credit, enough for extensive testing

Step 2: Choose a Model#

CCAPI uses provider/model-id format for all model IDs. Pick a model based on your needs:

Budget Models (Best Cost-to-Quality)#

Model IDContextInput / Output (per 1M tokens)Highlights
deepseek/deepseek-chat128K0.27/1.10DeepSeek V3. Best overall budget choice for OpenClaw. Strong coding, reasoning, and general tasks.
minimax/MiniMax-M2.51M0.21/0.84Cheapest coding model. SWE-bench 80.2%. 1M context window.
openai/gpt-5-nano1M0.035/0.28Ultra-low cost. Good for simple tasks, summaries, and classification.
google/gemini-2.5-flash1M0.105/0.42Fast, cheap, 1M context. Good for large codebase analysis.

Mid-Tier Models (Quality + Affordability)#

Model IDContextInput / Output (per 1M tokens)Highlights
openai/gpt-5-mini1M0.175/1.40GPT-5 family, fast and affordable. Good all-rounder.
deepseek/deepseek-reasoner128K0.55/2.19DeepSeek R1. Strong chain-of-thought reasoning.
z-ai/glm-5128K0.40/1.80Zhipu GLM-5. Excellent for Chinese language tasks.
google/gemini-2.5-pro1M0.875/7.00Google's best. 1M context, strong multimodal.

Premium Models (Maximum Quality)#

Model IDContextInput / Output (per 1M tokens)Highlights
openai/gpt-5.2256K1.225/9.80Latest GPT-5.2. Strongest OpenAI model.
openai/gpt-4o128K1.75/7.00GPT-4o multimodal. Proven quality for complex tasks.
openai/gpt-4.11M1.40/5.60GPT-4.1 with 1M context.

Vision-Capable Models (for screenshot analysis)#

If you use OpenClaw's screenshot/vision features, you need a vision-capable model:
Model IDInput / 1MNotes
google/gemini-2.5-flash$0.105Cheapest vision option
openai/gpt-5-mini$0.175Best vision value
google/gemini-2.5-pro$0.875Best Google vision
openai/gpt-4o$1.75Best overall vision quality
openai/gpt-5.2$1.225Latest GPT-5 vision

Step 3: Configure OpenClaw#

There are three ways to connect OpenClaw to CCAPI. Choose the one that fits your workflow.

Method A: Environment Variables (Simplest)#

The fastest way. Add these to your shell profile (~/.bashrc, ~/.zshrc) or OpenClaw's .env file:
Variable reference:
VariableRequiredDescription
OPENCLAW_BASE_URLYesMust be https://api.ccapi.ai/v1. This tells OpenClaw to send requests to CCAPI instead of OpenAI.
OPENCLAW_API_KEYYesYour CCAPI API key (starts with sk-). Get it from Dashboard > API Keys.
OPENCLAW_MODELYesDefault model ID in provider/model-id format. Example: deepseek/deepseek-chat.
OPENCLAW_FALLBACK_MODELNoBackup model used when the primary model fails or is overloaded. Example: openai/gpt-5-mini.
After setting the variables, restart your terminal and OpenClaw.

Method B: openclaw.json Config File (Most Flexible)#

For multi-model setups and advanced configuration. Edit ~/.openclaw/openclaw.json:
{
  "models": {
    "providers": {
      "ccapi": {
        "baseUrl": "https://api.ccapi.ai/v1",
        "apiKey": "$CCAPI_API_KEY",
        "api": "openai-completions",
        "models": [
          "deepseek/deepseek-chat",
          "deepseek/deepseek-reasoner",
          "openai/gpt-5-mini",
          "openai/gpt-5-nano",
          "openai/gpt-4o",
          "google/gemini-2.5-flash",
          "google/gemini-2.5-pro",
          "z-ai/glm-5",
          "minimax/MiniMax-M2.5"
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "ccapi/deepseek/deepseek-chat"
      }
    }
  }
}
Config field reference:
FieldDescription
models.providers.ccapiRegisters CCAPI as a custom provider named "ccapi". You can use any name.
baseUrlCCAPI endpoint. Always https://api.ccapi.ai/v1.
apiKeyYour CCAPI API key. Use $CCAPI_API_KEY to reference an environment variable, or paste the key directly (less secure).
apiMust be "openai-completions". Tells OpenClaw to use the OpenAI chat completions protocol.
modelsArray of model IDs available through this provider. Only models listed here will appear in OpenClaw's model selector.
agents.defaults.model.primaryDefault model for new agent sessions. Format: provider-name/model-id where provider-name matches the key under models.providers (in this case ccapi).
Important notes:
The apiKey field supports env var syntax: "$CCAPI_API_KEY" reads from the CCAPI_API_KEY environment variable. This is more secure than hardcoding the key.
The models array determines which models OpenClaw offers you. You can list as many or as few as you want.
The primary model uses the format ccapi/deepseek/deepseek-chat — the first segment (ccapi) is the provider name you defined under models.providers, followed by the CCAPI model ID.

Method C: CLI Commands (Quick Setup)#

Use OpenClaw's built-in CLI to configure without editing files:
Verify the config was applied:

Step 4: Verify the Integration#

4.1 Test the API Key Directly#

Before testing in OpenClaw, verify your CCAPI key works:
You should get a JSON response with choices[0].message.content. If you see an error, check:
API key is correct (starts with sk-)
Model ID uses provider/model-id format
Account has balance (check at ccapi.ai/dashboard/billing)

4.2 Test Streaming#

You should see SSE events like data: {"choices":[{"delta":{"content":"1"}}]} streaming in.

4.3 Test in OpenClaw#

Start OpenClaw and give it a simple task:
What is 2 + 2?
If OpenClaw responds normally, the integration is working. You can check which model was used in OpenClaw's logs or the CCAPI Usage Dashboard.

4.4 Test Tool Calling#

OpenClaw relies heavily on tool/function calling (shell commands, file operations, web browsing). Verify:
List the files in the current directory.
OpenClaw should call a shell tool to run ls and return the output. All CCAPI text models support function calling.

4.5 Check Your Usage#

Monitor costs in real time at ccapi.ai/dashboard/usage. The dashboard shows:
Per-request token usage and cost
Daily/monthly spending breakdown
Model-by-model cost analysis

Step 5: Optimize Your Setup#

Recommended Configurations by Use Case#

Daily automation (~$3/month)
Best for: file management, web browsing, shell scripts, everyday tasks.
Coding assistant (~$8/month)
Best for: code review, debugging, refactoring. MiniMax M2.5 scores 80.2% on SWE-bench.
Quality-first (~$15/month)
Best for: complex reasoning, multi-step tasks, screenshot analysis.
Power user (~$30/month)
Best for: maximum quality, large codebase analysis, advanced reasoning.
Chinese language tasks
Best for: Chinese documentation, code with Chinese comments, Chinese web browsing.

Switching Models On-the-Fly#

With the openclaw.json method (Method B), you can list multiple models and switch between them during a session using OpenClaw's model selector — no restart needed.

Cost Comparison#

Estimated monthly cost at 50M tokens/day (typical heavy OpenClaw usage):
SetupModelEst. Monthly
Direct AnthropicClaude Opus~$2,250
Direct OpenAIGPT-4o~$750
CCAPIDeepSeek V3~$20
CCAPIMiniMax M2.5~$16
CCAPIGPT-5 Nano~$5
All CCAPI prices are final — no surcharge, no markup. Pay-as-you-go, no subscription.

Troubleshooting#

ProblemCauseSolution
Invalid API keyAPI key is incorrect or expiredVerify key at Dashboard > API Keys. Regenerate if needed.
Insufficient balanceAccount balance is $0Top up at Dashboard > Billing.
Model not foundWrong model ID formatUse provider/model-id format. Run curl https://api.ccapi.ai/v1/models -H 'Authorization: Bearer sk-...' to list all available models.
OpenClaw still uses OpenAIOPENCLAW_BASE_URL not set or overriddenVerify with echo $OPENCLAW_BASE_URL. Must be https://api.ccapi.ai/v1. Check for conflicting .env files.
Tool calls failModel doesn't support function callingAll CCAPI text models support function calling. Check the model ID is correct.
Streaming doesn't workNetwork proxy or firewall blocking SSETest with curl -N (streaming). Check proxy settings.
Slow responsesModel overloaded or network latencyTry a different model (e.g., gemini-2.5-flash is very fast). Check status.ccapi.ai.
Chinese models not availableUsing wrong provider prefixChinese models: z-ai/glm-5, minimax/MiniMax-M2.5, moonshot/moonshot-v1-128k, qwen/qwen-plus-latest. No special setup needed.

API Quick Reference#

Base URL: https://api.ccapi.ai/v1
Auth: Authorization: Bearer sk-your-ccapi-api-key
Endpoint: POST /v1/chat/completions
Model ID format: provider/model-id (e.g., deepseek/deepseek-chat, openai/gpt-4o)
Supported features: streaming, tool/function calling, vision (image input), JSON mode, system messages
Full API docs: docs.ccapi.ai

Request

Authorization
Bearer Token
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
or
Body Params application/json

Example
{
    "model": "deepseek/deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful AI assistant."
        },
        {
            "role": "user",
            "content": "Hello from OpenClaw!"
        }
    ],
    "stream": true,
    "max_tokens": 4096
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.ccapi.ai/api/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "deepseek/deepseek-chat",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful AI assistant."
        },
        {
            "role": "user",
            "content": "Hello from OpenClaw!"
        }
    ],
    "stream": true,
    "max_tokens": 4096
}'

Responses

🟢200成功
application/json
Chat completion response
Body

Example
{
    "id": "chatcmpl-abc123",
    "object": "chat.completion",
    "created": 1709000000,
    "model": "deepseek/deepseek-chat",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "Hello! I'm DeepSeek V3, running through CCAPI. How can I help you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 24,
        "completion_tokens": 18,
        "total_tokens": 42
    }
}
🟠400请求有误
🟠401未认证
🟠402需要付款
Modified at 2026-02-24 15:23:12
Next
Create Chat Completion
Built with