ClaudeCode Installation Guide

Claude Code Windows Official Package Installation Guide

System Requirements: Windows 10 (version 1809 / build 17763) and above

Installation Steps

1. [Desktop Step] Download Git

Visit https://git-scm.com/downloads/win, click Next for all installation steps, do not modify paths

2. [Desktop Step] Download Node.js

Visit https://nodejs.org/zh-cn/download, click Next for all installation steps, do not modify paths

3. [Windows PowerShell Step] Verify Installation

Open Windows PowerShell (blue icon), execute the following commands to verify installation:

PS> node -v PS> npm -v

4. [Windows PowerShell Step] Uninstall Existing Claude Code (skip if not installed)

PS> npm uninstall -g @anthropic-ai/claude-code

5. [Windows PowerShell Step] Install Official Package

PS> npm install -g @anthropic-ai/claude-code

6. [Control Panel Step] Set Windows System Environment Variables

The following three environment variables need to be set:

Variable Name: ANTHROPIC_BASE_URL https://claudecode.epiphanymind.com/api/claudecode
Variable Name: ANTHROPIC_API_KEY Your API Key
Variable Name: ANTHROPIC_AUTH_TOKEN Your API Key

For setup method, see "Prerequisites: Modifying Environment Variables" above

7. [Windows PowerShell Step] Restart Windows PowerShell, Verify Installation

After restarting Windows PowerShell, run the following command to confirm successful installation

PS> claude -v
Getting Started
After installation is complete, you can start using Claude Code in any project directory:
# Navigate to your project $ cd your-project-folder # Start Claude Code $ claude

Common Issues

Issue 1: Unable to connect to Anthropic services

Unable to connect to Anthropic services error screenshot

Issue 2: 401 Invalid token

401 Invalid token error screenshot
For Windows native users, if environment variables don't take effect after configuration, try the following steps:
1. Backup the "C:\users\your-username\.claude.json" file
2. Delete the "C:\users\your-username\.claude.json" file
3. Reopen Claude Code and select "yes" in the "yes/no(recommended)" dialog that appears

If Issue 1 persists after the above steps, execute the following:
Modify the "C:\users\your-username\.claude.json" file and add "hasCompletedOnboarding": true to the outermost JSON

macOS/Linux Official Package Installation Guide

System Requirements: macOS 10.15+ or Linux system

Installation Steps

1. Open Terminal

Use Cmd+Space to search for "Terminal" or find Terminal in Applications > Utilities

2. Uninstall Existing Claude Code (skip if not installed)

$ npm uninstall -g @anthropic-ai/claude-code

3. Install Official Package

$ npm install -g @anthropic-ai/claude-code

4. Create API Key in K2Sonnet Developer Center

Login to K2Sonnet Developer Center -> API Key Management -> Create API Key

5. Configure Environment Variables

Execute in terminal

export ANTHROPIC_BASE_URL=https://claudecode.epiphanymind.com/api/claudecode export ANTHROPIC_API_KEY=your-api-key-from-developer-center
Getting Started
After installation is complete, you can start using Claude Code in any project directory:
# Navigate to your project $ cd your-project-folder # Start Claude Code $ claude

First API Call

K2Sonnet is compatible with both OpenAI and Anthropic AI formats. Please call the corresponding base_url according to your needs.

OpenAI Format Call

PARAM VALUE
base_url * https://claudecode.epiphanymind.com/api/openai
api_key apply for an API key
curl https://claudecode.epiphanymind.com/api/openai \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your-api-key>" \ -d '{ "model": "k2sonnet-chat", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "stream": false }'
from openai import OpenAI client = OpenAI( api_key="<your-api-key>", base_url="https://claudecode.epiphanymind.com/api/openai" ) response = client.chat.completions.create( model="k2sonnet-chat", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], stream=false ) print(response.choices[0].message.content)
import OpenAI from "openai"; const openai = new OpenAI({ baseURL: 'https://claudecode.epiphanymind.com/api/openai', apiKey: '<your-api-key>' }); async function main() { const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Hello!" } ], model: "k2sonnet-chat", stream: false }); console.log(completion.choices[0].message.content); } main();

Response Information

{ "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "Hello! How can I help you today?", "role": "assistant" } } ], "created": 1756261434, "id": "0217562614339389fc4dc47d27ebf7239e22958e08dac0b945815", "model": "k2sonnet-chat", "service_tier": "default", "object": "chat.completion", "usage": { "completion_tokens": 8, "prompt_tokens": 140, "total_tokens": 148, "prompt_tokens_details": { "cached_tokens": 0 }, "completion_tokens_details": { "reasoning_tokens": 0 } } }
{"choices":[{"delta":{"content":"Hello","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":1,"prompt_tokens":140,"total_tokens":141,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":"!","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":2,"prompt_tokens":140,"total_tokens":142,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" How","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":3,"prompt_tokens":140,"total_tokens":143,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" can","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":4,"prompt_tokens":140,"total_tokens":144,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" I","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":5,"prompt_tokens":140,"total_tokens":145,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" help","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":6,"prompt_tokens":140,"total_tokens":146,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" you","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":7,"prompt_tokens":140,"total_tokens":147,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":" today","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":8,"prompt_tokens":140,"total_tokens":148,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":"?","role":"assistant"},"index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":9,"prompt_tokens":140,"total_tokens":149,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} {"choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":"stop","index":0}],"created":1756261652,"id":"021756261651547c6f5b907bfcacf189664f83e123db882f8f65b","model":"k2sonnet-chat","service_tier":"default","object":"chat.completion.chunk","usage":{"completion_tokens":8,"prompt_tokens":140,"total_tokens":148,"prompt_tokens_details":{"cached_tokens":0,"text_tokens":140},"completion_tokens_details":{"reasoning_tokens":0}}} [DONE]

Anthropic AI Format Call

PARAM VALUE
base_url * https://claudecode.epiphanymind.com/api/anthropic
api_key apply for an API key
curl https://claudecode.epiphanymind.com/api/anthropic \ -H "Content-Type: application/json" \ -H "x-api-key: <your-api-key>" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "k2sonnet-chat", "max_tokens": 1024, "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "stream": false }'
import requests url = "https://claudecode.epiphanymind.com/api/anthropic" headers = { "Content-Type": "application/json", "x-api-key": "<your-api-key>", "anthropic-version": "2023-06-01" } data = { "model": "k2sonnet-chat", "max_tokens": 1024, "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "stream": false } response = requests.post(url, headers=headers, json=data) print(response.json())
const axios = require('axios'); async function main() { const response = await axios.post( 'https://claudecode.epiphanymind.com/api/anthropic', { model: 'k2sonnet-chat', max_tokens: 1024, messages: [ { role: 'system', content: 'You are a helpful assistant.' }, { role: 'user', content: 'Hello!' } ], stream: false }, { headers: { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>', 'anthropic-version': '2023-06-01' } } ); console.log(response.data); } main();

Response Information

{ "id": "021756261314203c971ee90709fddbea289e41bb2f830ea68cf59", "type": "message", "role": "assistant", "model": "k2sonnet-chat", "content": [ { "type": "text", "text": "Hello! How can I help you today?" } ], "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 140, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "cache_creation": { "ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0 }, "output_tokens": 8, "service_tier": "default" } }
{"type":"message_start","message":{"id":"msg_68ae6c1a2a185","type":"message","role":"assistant","model":"k2sonnet-chat","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":140,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"default"}}} {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"!"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" How"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" can"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" I"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" help"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" you"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" today"}} {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"?"}} {"type":"content_block_stop","index":0} {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":140,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":8}} {"type":"message_stop"} [DONE]
* When using the OpenAI compatible interface, you can use existing OpenAI SDKs and tools by simply modifying the base_url parameter. The Anthropic native interface provides more complete functionality support.
* Our main model is k2sonnet-chat, an optimized conversational model that supports Chinese and English dialogue, code generation, and various other tasks.

Models & Pricing

The model prices listed in the table below are in units of "million tokens". A token is the smallest unit used by the model to represent natural language text, and can be a word, number, punctuation mark, etc. We will charge based on the total number of tokens input and output by the model.

Model Details

Model k2sonnet-chat
Model Version k2sonnet-chat (Optimized Version)
Context Length 128K
Output Length Default 4K, Max 32K
Json Output Supported
Function Calling Supported
Vision Capabilities Supported, using Doubao vision recognition, passed to k2sonnet-chat
Thinking Supported, with simulated thinking to greatly enhance programming capabilities

Pricing

Model k2sonnet-chat
Input (Million Tokens) ¥4
Output (Million Tokens) ¥12
缓存命中 暂不支持缓存命中

Billing Rules

Deduction = Token Consumption × Model Unit Price. The corresponding fees will be directly deducted from the recharged balance or gifted balance. When both recharged balance and gifted balance exist, gifted balance will be deducted first.

Product prices may change, and K2Sonnet reserves the right to modify prices. Please recharge according to actual usage as needed and check this page regularly for the latest pricing information.

Technical Notice: To maximize model capabilities, K2Sonnet team has implemented third-party model capability fusion, simulated thinking abilities, and API context expansion capabilities at the API layer. By using K2Sonnet's services, you acknowledge and agree to these technical solutions.

Token Usage Calculation

A token is the basic unit used by the model to represent natural language text, and is also our billing unit. It can be intuitively understood as a "character" or "word". Typically, 1 Chinese word, 1 English word, 1 number or 1 symbol counts as 1 token.

Token Conversion Ratio

Generally, the conversion ratio between tokens and character count in models is approximately as follows:

Text Type Conversion Ratio Example
English Characters 1 English character ≈ 0.3 tokens "Hello" ≈ 1.5 tokens
Chinese Characters 1 Chinese character ≈ 0.6 tokens "你好" ≈ 1.2 tokens
Numbers and Symbols 1 number or symbol ≈ 1 token "123!" ≈ 4 tokens
Note: Since different models have different tokenization methods, the conversion ratios may vary. The actual token count for each processing is based on the model's response, which you can view in the usage field of the returned results.