Duck Proxy is a high-performance, asynchronous local AI proxy server written in pure Rust that provides a standard OpenAI API endpoint (http://localhost:18080/v1).
Connect it seamlessly to OpenCode CLI, Cursor, VS Code (Continue / Cline / Roo Code), ZCode, Aider, Zed, Windsurf, Neovim, or any Python/Node.js application to access GPT-5.6 Luna, Claude Haiku 4.5, Mistral Small 2603, Google Gemma 4 31B, and native gpt-image 2.0 Image Generation through a unified local interface.
# 1. Install Rust compiler (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 2. Clone repository & launch in 1 command
git clone https://github.com/OmarElsiry/duck-proxy.git
cd duck-proxy
./duck:: 1. Install Rust via Winget (if not already installed)
winget install Rustlang.Rustup
:: 2. Clone repository & launch
git clone https://github.com/OmarElsiry/duck-proxy.git
cd duck-proxy
duck.bat# 1. Install Rust via Winget (if not already installed)
winget install Rustlang.Rustup
# 2. Clone repository & launch
git clone https://github.com/OmarElsiry/duck-proxy.git
cd duck-proxy
.\duck.ps1β‘ What happens automatically:
- Verifies/compiles the optimized release binary in pure Rust.
- Starts the background daemon on
http://127.0.0.1:18080.- Launches your default browser to the interactive dashboard (
http://localhost:18080/app).- Displays an instant status card with model catalog and quick-test curl commands.
- π€ Native AI Agent IDE Support: Full multi-turn agent tool execution, file operations, diff editing, and bash execution compatibility for OpenCode, Cursor, and Cline.
- π¨ Native
gpt-image 2.0Generation: Generates high-resolution images with official OpenAI C2PA metadata directly inside OpenCode TUI / CLI and via/v1/images/generationswith zero external fallbacks. - β‘ Zero-Config 1-Click Launch: Instant startup on Windows, Linux, and macOS with background daemonization.
- π‘οΈ Embedded V8 Runtime Engine: Integrated JavaScript engine (
deno_core) handles upstream browser-compatible protocol validation and cryptographic state seamlessly. - π Automatic Session Resilience: Stateful session lifecycle management and resilient connection pooling with exponential backoff.
- π¦ Tool Synthesizer & Format Normalization: Automatically extracts
<tool_call>, JSON blocks, and code blocks, translating them into executable client tools (bash,apply_patch). - π Strict OpenAI SSE Protocol: Full streaming compliance with
@ai-sdk/openai-compatible(role delta chunks, stop reason signaling, and UTF-8 multibyte boundary preservation). - π§ͺ Comprehensive 40-Scenario Test Suite: Built-in test harness verifying file ops, surgical edits, context pruning, tools, streaming, and subagent concurrency.
Every model has an exact official identifier as well as a convenient short alias. Both work identically:
| Model ID (Specific) | Short Alias | Upstream Engine | Creator | Context Window | Best Use Cases & Strengths |
|---|---|---|---|---|---|
gpt-5.6-luna |
gpt5 |
gpt-5.6-luna |
OpenAI | 128k / 200k | π₯ Primary Coding & Image Gen: Complex system architecture, multi-file refactoring, native gpt-image 2.0 |
claude-haiku-4-5 |
claude |
claude-haiku-4-5 |
Anthropic | 128k / 200k | β‘ Fast Code Review: Interactive editing, explaining bugs, writing unit tests |
mistral-small-2603 |
mistral |
mistral-small-2603 |
Mistral AI | 64k / 128k | π Speed & Logic: Direct mathematical logic, algorithms, concise scripts |
tinfoil/gemma4-31b |
gemma |
tinfoil/gemma4-31b |
Google / Tinfoil | 64k / 128k | π Privacy Focused: High-parameter open model with zero tracking guarantees |
gpt-5.4-mini |
gpt5_mini |
gpt-5.4-mini |
OpenAI | 64k / 128k | β±οΈ Lightweight: Fast syntax checks, quick Q&A, drafting git commit messages |
image-generation |
image |
gpt-image 2.0 |
OpenAI | β | π¨ Image Assets: Generates high-res image assets via /v1/images/generations or chat prompts |
Configure OpenCode in ~/.opencode/config.json (or ~/.config/opencode/config.json):
{
"providers": {
"duckproxy": {
"type": "openai-compatible",
"baseURL": "http://localhost:18080/v1",
"apiKey": "duck-proxy",
"models": [
"gpt-5.6-luna",
"claude-haiku-4-5",
"mistral-small-2603",
"tinfoil/gemma4-31b"
]
}
}
}Run autonomous coding tasks directly:
# Autonomous code editing
opencode run -m duckproxy/gpt-5.6-luna --auto "Refactor calculate_total to support discounts"
# Interactive agent session
opencode- Open Cursor Settings (
Ctrl+Shift+JorCmd+Shift+J) β Models. - Under OpenAI API Key, enter
duck-proxy. - Enable Override OpenAI Base URL and enter:
http://localhost:18080/v1 - Add models:
gpt-5.6-luna,claude-haiku-4-5,mistral-small-2603.
Add this block to your ~/.continue/config.json:
{
"models": [
{
"title": "Duck GPT-5.6 Luna",
"provider": "openai",
"model": "gpt-5.6-luna",
"apiBase": "http://localhost:18080/v1",
"apiKey": "duck-proxy"
},
{
"title": "Duck Claude Haiku 4.5",
"provider": "openai",
"model": "claude-haiku-4-5",
"apiBase": "http://localhost:18080/v1",
"apiKey": "duck-proxy"
}
]
}- Open Cline Settings β API Provider:
OpenAI Compatible. - Base URL:
http://localhost:18080/v1 - API Key:
duck-proxy - Model ID:
gpt-5.6-luna(orclaude-haiku-4-5) - Enable Supports Streaming.
export OPENAI_API_BASE="http://localhost:18080/v1"
export OPENAI_API_KEY="duck-proxy"
# Pair program with GPT-5.6 Luna
aider --model openai/gpt-5.6-lunaAdd to ~/.config/zed/settings.json:
{
"language_models": {
"openai": {
"api_url": "http://localhost:18080/v1",
"available_models": [
{ "name": "gpt-5.6-luna", "display_name": "GPT-5.6 Luna", "max_tokens": 8192 },
{ "name": "claude-haiku-4-5", "display_name": "Claude Haiku 4.5", "max_tokens": 8192 }
]
}
}
}from openai import OpenAI
client = OpenAI(
base_url="http://localhost:18080/v1",
api_key="duck-proxy"
)
# Real-time streaming response
stream = client.chat.completions.create(
model="gpt-5.6-luna",
messages=[{"role": "user", "content": "Explain async rust in 2 sentences."}],
stream=True
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)Run image generation directly in your terminal; OpenCode decodes the base64 stream, writes the image to disk, and displays the full resolved path:
opencode run -m duckproxy/gpt-5.6-luna --auto "gen img of a knight in shining armor"curl http://localhost:18080/v1/images/generations \
-H "Content-Type: application/json" \
-d '{"prompt": "minimalist glowing cyber duck logo, geometric art", "response_format": "b64_json"}'Duck Proxy comes with a dual-tier testing matrix covering 8 core agent IDE domains:
# Tier 1: Run Rust native unit & protocol tests (< 2 seconds)
cargo test
# Tier 2: Run full 40-scenario Agent IDE test matrix (offline mock mode)
python3 tests/harness/run_agent_suite.py --mode mock
# Tier 2: Run in live mode against upstream models
python3 tests/harness/run_agent_suite.py --mode live --model duckproxy/gpt-5.6-luna
# Target a specific domain (e.g. Surgical Editing or File Ops)
python3 tests/harness/run_agent_suite.py --domain surgical_edit- File Generation & Creation: Single files, directory trees, Arabic UTF-8, collision overwrite policies, empty module stubs.
- Surgical Code Editing: In-place statement replacement, multi-block non-adjacent edits, 4-space indentation preservation, cross-file refactoring, dirty patch recovery.
- Context Assembly & Memory: System permissions injection, workspace rules enforcement, 7,500 char sliding window truncation, multi-turn memory recall.
- Tool Calling & Multi-Turn Loops: OpenAI
tool_callsschema, fallback extraction, multi-turn test/fix cycles, parameter normalization. - SSE Streaming & Wire Compliance: Initial role chunking, real-time token deltas, finish reason signaling (
stopvstool_calls), multibyte boundary assembly, stream cancellation. - Model Routing & Resilience: Model alias mapping, V8 protocol evaluation, 429 backoffs & token rotation, payload character limits, candidate cascade fallbacks.
- Subagents & Task Concurrency: Subagent isolated workspaces, inter-agent result passing, daemon background persistence, multi-session concurrency, deadlock timeout guards.
- Edge Cases & Safety: Binary file safety, 20-step iteration guards, 400 Bad Request handling, log stream truncation, exit code fidelity.
# Start container in background
docker compose up -d
# View live logs
docker compose logs -f
# Stop container
docker compose downDual-licensed under either MIT License or Apache License 2.0.