unoca (UnOpenCodeAPI) is a high-performance Go proxy and router designed to forward requests to the OpenCode API without requiring a personal API Key. By leveraging free public proxies and continuously verifying their validity and rate-limit status, unoca provides a seamless, OpenAI-compatible API interface.
- OpenAI Compatible Endpoint: Exposes OpenAI-compatible routes (
/v1/modelsand/v1/chat/completions) on a single port (20120). - Public Proxy Fetching & Parsing: Scrapes proxies from 13+ public sources (ProxyScrape, free-proxy-list, GitHub repositories, etc.) and parses multiple format specs (
socks5://IP:PORT,IP:PORT:Country, etc.). - Smart Filtering & Protocol Priority: Filters private/invalid IPs (
0.0.0.0,127.x.x.x,10.x.x.x,192.168.x.x) and prioritizes protocols: SOCKS5 > SOCKS4 > HTTPS > HTTP. - Two-Step Proxy Validation:
- Connection & GeoIP Check: Verifies connectivity via
https://ipinfo.io/json(5s timeout) to acquire ISO country flags and separate dead proxies from timeouts. - AI Prompt Validation: Sends sample test prompts (
1+1=?, etc.) to OpenCode API to check actual availability (alivevsrate_limit).
- Connection & GeoIP Check: Verifies connectivity via
- Embedded Admin Dashboard: Access a full UI at
http://localhost:20120/dashboard/endpointfeaturing 4 tabs:- Endpoint: Quick setup guides, base URL, and active proxy stats.
- Usage: Detailed token counting, estimated cost display, a Smoothed Area Chart (00:00–23:59 daily usage), and a Contribution Heatmap Graph (365-day tracking).
- System Logs: Internal runtime and API error logs.
- Proxy Pools: Filterable, sortable, and paginated proxy table with country flags and latency metrics.
- Embedded SQLite Storage (
unoca.db): Stores proxy pool state and usage data via CGO-free pure Go SQLite (modernc.org/sqlite). Automatic prune routines clean up old logs before application start. - Auto & Manual Proxy Scans: Automatic scan cycle every 24 hours with an instant "Refresh Proxies" trigger in the admin UI.
- Go:
1.22or1.25installed.
-
Clone the repository and navigate to the source directory:
cd d:\project\UnOpenCodeAPI\uncodeapi
-
Tidy dependencies:
go mod tidy
-
Run directly or build the binary:
# Run directly go run cmd/unoca/main.go # Or build binary go build -o unoca.exe cmd/unoca/main.go ./unoca.exe
Upon startup, unoca creates unoca.db in the working directory and serves the proxy and Web UI at http://localhost:20120.
Configure any OpenAI SDK or client (e.g., Python openai, LangChain, NextChat) to point to unoca:
- Base URL:
http://localhost:20120/v1 - API Key: Any dummy string (e.g.,
sk-unoca-free)
curl http://localhost:20120/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-unoca-free" \
-d '{
"model": "opencode-free",
"messages": [{"role": "user", "content": "Hello!"}]
}'Open http://localhost:20120 in your web browser to open the Admin UI:
- Endpoint: Displays the active Base URL
http://localhost:20120/v1and connection test buttons. - Usage: Shows Input/Output token counts, estimated costs, Smoothed Area Chart (daily 24h timeline), and Contribution Heatmap Graph (yearly activity).
- System Logs: Displays internal logs, including HTTP 429 rate limit events.
- Proxy Pools: Provides pagination, search, protocol filters, and manual proxy refreshing.
unoca uses a local SQLite database named unoca.db placed alongside unoca.exe:
- WAL Mode: Optimized for low IO overhead.
- Automatic Prune: Before printing the startup banner,
unocaautomatically purges expired log lines and outdated daily usage records.
While all three tools aim to provide API access to OpenCode Zen, unoca operates on a completely different core design:
- Focus & Simplicity:
- 9router / OmniRoute: Centralized router/proxy platforms aggregating multiple cloud services, often requiring account sign-ups, credit cards, or unofficial/internal API keys.
unoca: Exclusively focused on public OpenCode Zen endpoints using IP-based rate limiting without needing any account or API keys.
- Proactive & Automated Proxy Management:
unoca: Automatically fetches and ingests 100,000+ proxies from 13+ public sources, proactively testing and validating each proxy directly against OpenCode Zen rate limits (FreeUsageLimitError/429).- 9router / OmniRoute: Passive design requiring manual proxy entry and management by the user.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.