Skip to content

sontianye/qoder-api

Repository files navigation

qoder-api

Python 3.11+ FastAPI License: MIT

Anthropic-compatible API proxy for Qoder via qodercli.

Expose Qoder's AI capabilities through an Anthropic-compatible API, enabling Claude Code and other Anthropic clients to use Qoder's models (Qwen/GLM/Kimi) seamlessly.

Features

  • Anthropic API compatible — Drop-in replacement for api.anthropic.com
  • Streaming & non-streaming — Full SSE streaming support
  • Model mapping — Claude model names automatically mapped to Qoder tiers
  • Tool support — Structured tool calling with automatic execution via qodercli
  • Docker ready — One-command deployment with Docker Compose

Prerequisites

  • Python >= 3.11
  • qodercli installed and authenticated
  • Qoder Personal Access Token

Quick Start

# 1. Clone and install
git clone https://github.com/sontianye/qoder-api.git
cd qoder-api
uv sync --extra dev

# 2. Configure
cp .env.example .env
# Edit .env and set QODER_PERSONAL_ACCESS_TOKEN

# 3. Run
uv run python -m qoder_api.main

The server will start at http://localhost:8000.

Docker

cp .env.example .env
# Edit .env with your token
docker compose up --build

Usage with Claude Code

export ANTHROPIC_BASE_URL=http://localhost:8000
export ANTHROPIC_API_KEY=any
claude

API Endpoints

Endpoint Description
GET /health Health check
POST /v1/messages Chat completions (streaming + non-streaming)
POST /v1/messages/count_tokens Token estimation stub

Configuration

Variable Default Description
QODER_PERSONAL_ACCESS_TOKEN Required qodercli auth token
QODERCLI_PATH qodercli qodercli binary path
QODER_TIMEOUT 120 Request timeout (seconds)
DEFAULT_MODEL_TIER auto Default model tier
MAX_CONVERSATION_TURNS 20 Conversation history limit
DISALLOWED_TOOLS Bash,Edit,Write,... Blocked qodercli tools (security)
MAX_TURNS 1 Max agent iterations (security)
MAX_CONCURRENT_REQUESTS 10 Concurrent request limit
ENABLE_IMAGES false Experimental image support
ENABLE_NATIVE_TOOLS true Use native function calling
API_KEY Optional proxy API key
HOST 0.0.0.0 Bind address
PORT 8000 Listen port
LOG_LEVEL INFO Logging level

See .env.example for all options.

Development

# Run tests
uv run pytest

# Run with hot reload (for development)
uv run uvicorn qoder_api.main:app --reload

Architecture

Claude Code → qoder-api → qodercli → Qoder Backend
                ↓
        Anthropic-compatible
        request/response format

License

MIT

About

Anthropic-compatible API proxy for Qoder via qodercli

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors