Skip to content

stein-exe/freeclaude-code

Repository files navigation

opencode-to-claude

Telegram Telegram Telegram Python

Route Claude Code API requests through a local proxy to free models at opencode.ai/zen.

Instead of paying for Anthropic API access, this proxy translates Claude Code's requests and forwards them to opencode.ai's free model endpoints.


How it works

claude (your terminal)
    → proxy.py (localhost:57319)
        → opencode.ai/zen API (free models)
            → proxy.py
                → claude (response)

Install

1. Install Python 3.9+

Download from python.org. Make sure Python is in your PATH.

2. Install proxy dependencies

pip install -r requirements.txt

3. Install opencode CLI

npm install -g opencode

Verify:

opencode --version

4. Install Claude Code

Follow the guide at docs.anthropic.com.


Setup

Step 1 — Start the proxy

python proxy.py

The proxy runs on port 57319 by default. You'll see:

  MODE: routing
  claude-opus-*   →  deepseek-0v4-5-free
  claude-sonnet-* →  mimo-2025-06-24
  claude-haiku-*  →  mimo-2025-06-24

  listening on http://127.0.0.1:57319

Keep the proxy running in a separate terminal.

Step 2 — Run Claude Code with the proxy config

# Routing mode (different models per tier)
claude --use-claude-code-settings settings.routing.json

# Direct mode (all requests to one model)
claude --use-claude-code-settings settings.direct.json

Step 3 — (Optional) Apply a custom system prompt

claude-fable-5.md is the real, unmodified system prompt of Claude Fable 5.
claude-system-prompt-essential.md is a cleaned-up version. Use this one — it works more beneficially with the proxy.

You can access more prompts by clicking here.

Load it in Claude Code:

/prompt < path/to/claude-system-prompt-essential.md

Configuration

Routing mode (default)

Routes requests by Claude model tier:

Claude model opencode.ai model
claude-opus-* deepseek-0v4-5-free
claude-sonnet-* mimo-2025-06-24
claude-haiku-* mimo-2025-06-24

Config: settings.routing.json

Fixed mode

Routes all requests to a single model. Set via env var:

OC_MODEL=mimo-2025-08 python proxy.py

Config: settings.direct.json


Environment variables

Variable Default Description
OC_KEY opencode.ai API key (optional)
PORT 57319 proxy listen port
OC_MODEL fixed model override (enables fixed mode)
OC_OPUS deepseek-0v4-5-free model for opus requests
OC_SONNET mimo-2025-06-24 model for Sonnet requests
OC_HAIKU mimo-2025-06-24 model for Haiku requests

Health check

curl http://127.0.0.1:57319/health

Files

File Description
proxy.py the proxy server
settings.routing.json Claude Code config for routing mode
settings.direct.json Claude Code config for fixed mode
claude-system-prompt-essential.md recommended custom system prompt
claude-fable-5.md real Claude Fable 5 system prompt

Credits

By stein

Telegram Telegram Telegram GitHub


Requirements

  • Python 3.9+
  • Network access to opencode.ai/zen

About

Local proxy that routes Claude Code to opencode.ai free models. No API key needed.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages