Alishahryar1 / free-claude-code

Alishahryar1 / free-claude-code

🤖 Free Claude Code Use Claude Code CLI, VS Code, JetBrains ACP, or chat bots through your own Anthropic-compatible proxy. Free Claude Code routes Anthropic Messages API traffic from Claude Code to NVIDIA NIM, OpenRouter, DeepSeek, LM Studio, llama.cpp, or Ollama. It keeps Claude Code’s client-side protocol stable while letting you choose free, paid, or local models.

🤖 Free Claude Code 通过你自己的 Anthropic 兼容代理使用 Claude Code CLI、VS Code、JetBrains ACP 或聊天机器人。Free Claude Code 将来自 Claude Code 的 Anthropic Messages API 流量路由到 NVIDIA NIM、OpenRouter、DeepSeek、LM Studio、llama.cpp 或 Ollama。它在保持 Claude Code 客户端协议稳定的同时,让你能够自由选择免费、付费或本地模型。


What You Get

  • Drop-in proxy for Claude Code’s Anthropic API calls.
  • Six provider backends: NVIDIA NIM, OpenRouter, DeepSeek, LM Studio, llama.cpp, and Ollama.
  • Per-model routing: send Opus, Sonnet, Haiku, and fallback traffic to different providers.
  • Streaming, tool use, reasoning/thinking block handling, and local request optimizations.
  • Optional Discord or Telegram bot wrapper for remote coding sessions.
  • Optional voice-note transcription through local Whisper or NVIDIA NIM.

你将获得

  • Claude Code 的 Anthropic API 调用即插即用代理。
  • 六种后端提供商:NVIDIA NIM、OpenRouter、DeepSeek、LM Studio、llama.cpp 和 Ollama。
  • 按模型路由:将 Opus、Sonnet、Haiku 及回退流量发送到不同的提供商。
  • 支持流式传输、工具调用、推理/思考块处理以及本地请求优化。
  • 可选的 Discord 或 Telegram 机器人封装,用于远程编码会话。
  • 通过本地 Whisper 或 NVIDIA NIM 实现的可选语音笔记转录。

Quick Start

1. Install Requirements

Install Claude Code, then install uv and Python 3.14. macOS/Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh
uv self update
uv python install 3.14

Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv self update
uv python install 3.14

快速开始

1. 安装要求

安装 Claude Code,然后安装 uv 和 Python 3.14。 macOS/Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh
uv self update
uv python install 3.14

Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv self update
uv python install 3.14

2. Clone And Configure

git clone https://github.com/Alishahryar1/free-claude-code.git
cd free-claude-code
cp .env.example .env

PowerShell uses: Copy-Item .env.example .env

Edit .env and choose one provider. For the default NVIDIA NIM path:

NVIDIA_NIM_API_KEY="nvapi-your-key"
MODEL="nvidia_nim/z-ai/glm4.7"
ANTHROPIC_AUTH_TOKEN="freecc"

Use any local secret for ANTHROPIC_AUTH_TOKEN; Claude Code will send the same value back to this proxy. Leave it empty only for local/private testing.

2. 克隆并配置

git clone https://github.com/Alishahryar1/free-claude-code.git
cd free-claude-code
cp .env.example .env

PowerShell 使用: Copy-Item .env.example .env

编辑 .env 并选择一个提供商。以默认的 NVIDIA NIM 路径为例:

NVIDIA_NIM_API_KEY="nvapi-your-key"
MODEL="nvidia_nim/z-ai/glm4.7"
ANTHROPIC_AUTH_TOKEN="freecc"

ANTHROPIC_AUTH_TOKEN 可以使用任何本地密钥;Claude Code 会将相同的值发送回此代理。仅在本地/私有测试时可留空。


3. Start The Proxy

uv run uvicorn server:app --host 0.0.0.0 --port 8082

Package install alternative:

uv tool install git+https://github.com/Alishahryar1/free-claude-code.git
fcc-init
free-claude-code

fcc-init creates ~/.config/free-claude-code/.env from the bundled template.

3. 启动代理

uv run uvicorn server:app --host 0.0.0.0 --port 8082

包安装替代方案:

uv tool install git+https://github.com/Alishahryar1/free-claude-code.git
fcc-init
free-claude-code

fcc-init 会根据内置模板创建 ~/.config/free-claude-code/.env 文件。


4. Run Claude Code

Point ANTHROPIC_BASE_URL at the proxy root. Do not append /v1.

PowerShell:

$env:ANTHROPIC_AUTH_TOKEN="freecc"; $env:ANTHROPIC_BASE_URL="http://localhost:8082"; claude

Bash:

ANTHROPIC_AUTH_TOKEN="freecc" ANTHROPIC_BASE_URL="http://localhost:8082" claude

4. 运行 Claude Code

ANTHROPIC_BASE_URL 指向代理根目录。不要添加 /v1

PowerShell:

$env:ANTHROPIC_AUTH_TOKEN="freecc"; $env:ANTHROPIC_BASE_URL="http://localhost:8082"; claude

Bash:

ANTHROPIC_AUTH_TOKEN="freecc" ANTHROPIC_BASE_URL="http://localhost:8082" claude

Choose A Provider

Model values use this format: provider_id/model/name. MODEL is the fallback. MODEL_OPUS, MODEL_SONNET, and MODEL_HAIKU override routing for requests that Claude Code sends for those tiers.

选择提供商

模型值使用此格式:provider_id/model/nameMODEL 是回退模型。MODEL_OPUSMODEL_SONNETMODEL_HAIKU 会覆盖 Claude Code 为这些层级发送的请求路由。

(Note: For brevity, the provider table and specific configuration details for each service follow the same pattern of implementation.)

(注:为简洁起见,各服务提供商的表格及具体配置细节均遵循相同的实现模式。)