Skip to content

Claude

claude mainly supports claude-sonnet-4-6 and claude-opus-4-6

  • 2024.03.06 This site already supports claude-3-sonnet-20240229 claude-3-opus-20240229
  • Pricing is 50% off the official rate Official Pricing
  • Model parameter reference
  • Maximum input supports 120K tokens, maximum output supports 4096 (suitable for writing long-form content)
  • How to use: visit https://claude-3.ddaiai.com and see the Online Test section below
  • Supported models: claude-3-sonnet-20240229 claude-3-opus-20240229 claude-3-5-sonnet-20240620 claude-3-haiku-20240307

Online Test

Note 1. Visit https://claude-3.ddaiai.com (if blocked, try changing the subdomain prefix to suibian)


2. If you find it blocked, you can change the address yourself: https://suibian.ddaiai.com — replace suibian with something else, e.g. https://2024.ddaiai.com, all work

Settings

Then configure in the corresponding fields shown below: OpenAi API Base URL: https://api.openai-hk.com OpenAi API KEY: hk-your-apiKey

cover

Result

  • Set the model to claude-sonnet-4-6
  • Type your question in the input box cover

Claude API

OpenAI Chat Mode

Already aligned with the OpenAI interface — just change the model name

shell
curl --request POST \
  --url https://api.openai-hk.com/v1/chat/completions \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
    "max_tokens": 800,
    "model": "claude-3-sonnet-20240229",
    "temperature": 0.8,
    "top_p": 1,
    "presence_penalty": 1,
    "stream":false,
    "messages": [
        {
            "role": "system",
            "content": "You are Claude, a large language model trained by Anthropic. Answer as concisely as possible."
        },
        {
            "role": "user",
            "content": "Who are you? Please introduce yourself and your capabilities."
        }
    ]
}'
curl --request POST \
  --url https://api.openai-hk.com/v1/chat/completions \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
    "max_tokens": 800,
    "model": "claude-3-sonnet-20240229",
    "temperature": 0.8,
    "top_p": 1,
    "presence_penalty": 1,
    "stream":false,
    "messages": [
        {
            "role": "system",
            "content": "You are Claude, a large language model trained by Anthropic. Answer as concisely as possible."
        },
        {
            "role": "user",
            "content": "Who are you? Please introduce yourself and your capabilities."
        }
    ]
}'

Claude Native Mode

Using the native /v1/messages endpoint, see official docs

shell
curl https://api.openai-hk.com/v1/messages \
     --header "x-api-key: hk-your-key" \
     --header "anthropic-version: 2023-06-01" \
     --header "content-type: application/json" \
     --data \
'{
    "model": "claude-3-5-sonnet-20240620",
    "max_tokens": 1024,
    "messages": [
        {"role": "user", "content": "Hello, world"}
    ]
}'
curl https://api.openai-hk.com/v1/messages \
     --header "x-api-key: hk-your-key" \
     --header "anthropic-version: 2023-06-01" \
     --header "content-type: application/json" \
     --data \
'{
    "model": "claude-3-5-sonnet-20240620",
    "max_tokens": 1024,
    "messages": [
        {"role": "user", "content": "Hello, world"}
    ]
}'

Claude Native Billing

  • Billing reference: https://docs.anthropic.com/zh-CN/docs/build-with-claude/prompt-caching

  • Involves: base input tokens, cache write tokens, cache hit tokens, output tokens

    json
    {
      "input_tokens": 3,
      "cache_creation_input_tokens": 13598,
      "cache_read_input_tokens": 20,
      "output_tokens": 1
    }
    {
      "input_tokens": 3,
      "cache_creation_input_tokens": 13598,
      "cache_read_input_tokens": 20,
      "output_tokens": 1
    }
  • Pricing: cache write is 1.25x input, cache hit is 0.1x input, output is 5x input

  • For the example above: input tokens = 3 + 13598×1.25 + 20×0.1 = 17002.5

  • Some tools use the caching mechanism — please understand this before use

  • In openai-hk, cache_creation_input_tokens and cache_read_input_tokens are added to input_tokens at a certain multiplier

Claude Code Configuration

  • Update environment variables
shell
export ANTHROPIC_AUTH_TOKEN=hk-your-key  # Replace with your actual API Key
export ANTHROPIC_BASE_URL=https://api.openai-hk.com  # Replace with the actual Base URL provided by the platform
export ANTHROPIC_AUTH_TOKEN=hk-your-key  # Replace with your actual API Key
export ANTHROPIC_BASE_URL=https://api.openai-hk.com  # Replace with the actual Base URL provided by the platform
  • Add the above code to the end of your shell config file (e.g. ~/.bashrc, ~/.zshrc, ~/.profile). After saving, run source ~/.your_shell_config (e.g. source ~/.zshrc) or restart the terminal to make the config permanent
  • Install
shell
npm install -g @anthropic-ai/claude-code
claude --version # Expected output similar to: 1.0.120 (Claude Code)
npm install -g @anthropic-ai/claude-code
claude --version # Expected output similar to: 1.0.120 (Claude Code)
  • Run
shell
claude
claude

claude code

  • After the project exits, a billing summary is shown
shell
Total cost:            $0.2726
Total duration (API):  48.7s
Total duration (wall): 9m 39.8s
Total code changes:    0 lines added, 0 lines removed
Usage by model:
    claude-3-5-haiku:  1.8k input, 81 output, 0 cache read, 0 cache write ($0.0018)
       claude-sonnet:  4.0k input, 902 output, 34.5k cache read, 62.7k cache write ($0.2709)
Total cost:            $0.2726
Total duration (API):  48.7s
Total duration (wall): 9m 39.8s
Total code changes:    0 lines added, 0 lines removed
Usage by model:
    claude-3-5-haiku:  1.8k input, 81 output, 0 cache read, 0 cache write ($0.0018)
       claude-sonnet:  4.0k input, 902 output, 34.5k cache read, 62.7k cache write ($0.2709)

Configure Environment with cc switch

  • Use cc switch to configure the environment for the claude-code CLI tool

  • Download cc-switch

  • macOS download Windows download

  • Add a new provider Add provider

  • Add a unified provider Add provider

  • Fill in the unified provider details

    • Name is openai-hk
    • API URL is https://api.openai-hk.com
    • apiKey is hk-your-apiKey — get this key at https://www.openai-hk.com/v3/ai/key
    • Sub-keys can be created under the claude code group; the exchange rate is 2, which is 0.29 of the official price (2/7) Add provider
    • Enable claude code openai codex gemini CLIAdd provider
    • Configure models as shown below Add provider
    • Click Add
  • Sync

    • Go back to Add New Provider and you will see openai-hkAdd provider
    • Find "Sync to App" Add provider
    • Select Sync Add provider
  • Enable

    • Return to the main screen, find openai-hk and click Enable Enable