Skip to content

Claude Code

1. Claude Code + MaaS

Only supports Claude series models

Claude code

# Install    Node.js 18 or higher required
npm install -g @anthropic-ai/claude-code

# Environment variables
export ANTHROPIC_AUTH_TOKEN="{YOUR_API_KEY}"
export ANTHROPIC_BASE_URL="https://genaiapi.cloudsway.net/{YOUR_ENDPOINT}"
export ANTHROPIC_MODEL="claude-sonnet-4@20250514"
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"
export ENABLE_TOOL_SEARCH="0"

# Start claude code
claude    # Run claude from any directory

2. Claude Code + LiteLLM + MaaS

Supports MaaS platform to connect to models in OpenAI format

1. PostgreSQL database

docker pull postgres
docker run --name my-postgres -e POSTGRES_PASSWORD=123456 -p 5432:5432 -d postgres
docker exec -it my-postgres bash
psql -U postgres
CREATE DATABASE mydatabase;

2. LiteLLM

2.1 Configure config.yaml and place it in a custom folder (this address will be used in Step 2)

      model_list:
        - model_name: claude-4-6-opus                            # Model name, parameter to pass when calling the LLM API
          litellm_params:
            model: anthropic/claude-4-6-opus-20260205
            api_base: https://genaiapi.cloudsway.net/{endpoint}/v1/messages
            api_key: os.environ/CA_CLOUDSWAY_OPENAI_API_KEY      # Automatically converted to x-api-key: Bearer xxx
        - model_name: gemini-3.1-pro-preview
          litellm_params:
            model: openai/gemini-3.1-pro-preview
            api_base: https://genaiapi.cloudsway.net/v1/ai/{endpoint}
            api_key: os.environ/CA_CLOUDSWAY_OPENAI_API_KEY
        - model_name: gpt-5.3-codex
          litellm_params:
            model: openai/responses/gpt-5.3-codex
            api_base: https://genaiapi.cloudsway.net/v1/ai/{endpoint}
            api_key: xxx/CA_CLOUDSWAY_OPENAI_API_KEY
      general_settings:
        store_model_in_db: true
        master_key: 'sk-1234'
      litellm_settings:
        drop_params: true

2.2 Start

docker pull ghcr.io/berriai/litellm:main-latest

docker run \
    -v $(pwd)/config.yaml:/app/config.yaml \
    -p 4000:4000 \
    ghcr.io/berriai/litellm:v1.81.14-stable \
    --config /app/config.yaml --detailed_debug

2.3 Model Invocation

# View which models are configured in config.yaml
curl http://127.0.0.1:4000/v1/models \
--header 'Authorization: Bearer sk-1234' 

# Generate authentication key for model claude-4-6-opus
curl 'http://0.0.0.0:4000/key/generate' \
--header 'Authorization: Bearer sk-1234' \
--header 'Content-Type: application/json' \
--data-raw '{"models": ["claude-4-6-opus "], "metadata": {"user": "ishaan@berri.ai"}}'
# Returns {"key": "sk-wnm6JQ-f1U2Sixpa8L-0xg"}

# Call model API
curl --location --request POST 'http://127.0.0.1:4000/chat/completions' \
--header 'Authorization: Bearer sk-wnm6JQ-f1U2Sixpa8L-0xg' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "claude-4-6-opus ",
    "max_tokens": 2000,
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": "What is the weather like in San Francisco?"
        }
    ]
}'

3. Claude code

3.1 Using Claude Code

# Install    Node.js 18 or higher required
npm install -g @anthropic-ai/claude-code

# Environment variables
export ANTHROPIC_BASE_URL=http://127.0.0.1:4000    # LiteLLM IP and port
export ANTHROPIC_MODEL=claude-4-6-opus             # Which model to call
export ANTHROPIC_AUTH_TOKEN=sk-1234                # Authentication key

# Start claude code
claude    # Run claude from any directory

3.2 claude code ui

http://{claude code ip}:{claude code port}/ui/

Username: admin
Password: sk-1234