ClaudeCode Installation Guide

Claude Code Windows Official Package Installation Guide

System Requirements: Windows 10 and above

Installation Steps

1. [Desktop Step] Download Git

访问 https://git-scm.com/downloads/win,安装时全都下一步,不要修改路径

2. 【此步骤在桌面】下载nodejs

访问 https://nodejs.org/zh-cn/download,安装时全都下一步,不要修改路径

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

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

Cline调用方法

Cline是一个强大的AI代码助手,通过VS Code扩展提供智能编码支持。本指南将帮助您配置Cline以使用K2Sonnet API。

安装与配置

步骤 1: 安装Cline扩展

在VS Code中安装Cline扩展:

  1. 打开VS Code
  2. 按 Ctrl+Shift+X 打开扩展市场
  3. 搜索 "Cline"
  4. 点击安装

步骤 2: 配置API设置

安装完成后,配置Cline使用K2Sonnet API。您可以选择以下两种配置方式之一:

方法一:使用 Anthropic API Provider

  1. 点击VS Code左侧的Cline图标
  2. 选择 "Anthropic" 作为API提供商
  3. 配置以下设置:
参数
API Base URL https://claudecode.epiphanymind.com/api/anthropic
API Key 你的密钥

方法二:使用 OpenAI Compatible API Provider

  1. 点击VS Code左侧的Cline图标
  2. 选择 "OpenAI Compatible" 作为API提供商
  3. 配置以下设置:
参数
API Base URL https://claudecode.epiphanymind.com/api/openai
API Key 你的密钥

步骤 3: 开始使用

配置完成后,您可以:

  • 通过聊天界面与AI助手交流
  • 请求代码生成和重构建议
  • 获得代码解释和调试帮助
  • 让AI助手执行文件操作和项目管理任务

使用示例

以下是一些常见的使用场景:

代码生成

请帮我创建一个React组件,用于显示用户信息卡片,包含头像、姓名和邮箱

代码重构

请帮我重构这个函数,使其更加简洁易读

项目设置

请帮我创建一个新的Node.js项目,包含Express服务器和基本的路由设置

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.

Due to the widespread attention received by the new product launch, the current system load is high. To ensure service quality, k2sonnet-chat currently supports only 5 concurrent requests. We are actively coordinating resources to enhance user experience. Thank you for your understanding and support.

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
Thinking Supported

Pricing

Model k2sonnet-chat
Input Uncached (Million Tokens) $1.5
Output (Million Tokens) $5
Input Cached (Million Tokens) $0.2

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.

Resource Pack Billing

  • Uncached Input: Actual input tokens deducted from resource pack tokens at 1:1 ratio. Example: 10,000 input tokens deducts 10,000 tokens from resource pack
  • Cached Input: Actual input tokens divided by 7.5 deducted from resource pack. Example: 10,000 cached tokens deducts only 1,333.33 tokens from resource pack
  • Output: No discount, actual output tokens deducted from resource pack at 1:1 ratio. Example: 10,000 output tokens deducts 10,000 tokens from resource pack

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.