JuCode
2026.05 – 2026.11 · Team project, open source · Go, Rust, Tauri, React
JuCode is a multi-provider LLM gateway for AI coding tools. A user gets one API key and calls models from many vendors inside tools such as Codex, Claude Code and Cursor, billed by usage. I worked on it from 2026-05 with a small team, and most of the commits for the backend, front end and each client are mine. Service stopped on 2026-11-20, and the code was open-sourced under Apache-2.0 the same month.
Open source
The code is at JuCode-Team/JuCode. One repository, three directories. Run docker compose up in the root to start a full instance.
| Directory | Content |
|---|---|
| backend | Go gateway and console backend: protocol conversion, upstream scheduling, billing, payment, status page |
| web | User console, admin console and product site |
| cli | Command-line coding Agent in Rust |

Product site home page (the public live page of 2026-09-27): one endpoint serves many coding tools. The page states 67 models, 10 vendors and 8 coding tools.
What I built
| Part | Content | Tech |
|---|---|---|
| Gateway and backend | Unified access, routing, billing, admin console APIs | Go, PostgreSQL, Redis |
| Console and product site | User console, admin console, model list, status page | React, TypeScript, Vite |
| Command-line Agent | A coding Agent in the terminal, can run headless | Rust |
| Desktop client | Runs JuCode, Claude Code, Codex and ACP-protocol Agents in one window | Tauri, Svelte 5 |
| Mobile client | Remotely view and operate sessions on a computer | Kotlin, SwiftUI |
| Docs site, company site | Integration docs, company website | Next.js, Astro |
Architecture

A request entering the gateway passes authentication, group selection and balance pre-deduction. Then an upstream is chosen and the request is sent. After it ends, the actual usage is settled.
- Three protocols coexist: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages. An upstream declares which ones it supports natively. On a match the request is passed through unchanged. Otherwise it is converted by configuration.
- Upstreams are a single layer: one upstream holds an endpoint, credentials, a protocol declaration and a health state. Business groups bind to upstreams directly.
- Scheduling is layered by priority. Within a layer, traffic is spread by weight times health, and sessions are sticky. An upstream that errors enters a cooldown.
- Edge nodes keep accounts locally in Redis. Usage events go to an on-disk queue and are then pushed back to the center.
Hard parts
Billing without loss or duplication
A streaming request must be sure there is money to charge before any output, and must settle by the real usage at the end. The design has three states: reserve, settle, release.
- Before the request starts, the estimated amount is frozen in a transaction. If the balance is not enough, the request is rejected.
- At settlement, the difference is refunded or charged. For a request that has already started output, the actual cost is charged, and the balance may go negative. When a stream is cancelled, usage is rebuilt from the output already sent, capped at the frozen amount, so no debt is created by guessing.
- Repeated settlement is idempotent. A background cleanup job fully refunds frozen amounts that were never settled before they expired. For video tasks, the charge and the "billed" flag are in the same transaction.
The order on edge nodes is also fixed: write the usage event to the file queue and fsync first, and only then settle the local reservation. The request ID sent by the client does not take part in billing. The server generates a billing ID for each request, so replaying the same request ID is billed again. This has a regression test.
How cached tokens are billed
Input is split into three mutually exclusive sets: cache miss, cache hit and cache write. Each has its own unit price, and the three add up to the full input length. Cache-write tokens are charged once at the write price and are not also charged at the input price. Anthropic's 5-minute and 1-hour caches are priced separately. When the upstream reports only a total, the split is estimated. The early implementation charged them stacked. Reconciliation found this, the rule was changed, and the rule was written into a portable spec document.
Retry in another group after failure
When all upstreams in the preferred group fail and no byte has been written to the client yet, the request can go to the next candidate group. There are four limits: the billing method must stay the same; the key's rate multiplier limit must not be exceeded; a request where the user pinned a group does not cross groups; images and videos do not cross groups. After a switch, the frozen amount is re-estimated with the new group's multiplier. Attempts are counted per group, with at most 2 switches across 3 groups.
Controlling a computer from a phone
A background process on the computer keeps an outbound WebSocket to the backend. The phone logs in with the same account and connects through a relay on the backend. The backend only checks the OAuth tokens of both ends and forwards bytes. Each connection does a Noise IK handshake between the phone and the computer, so the relay cannot see the content and holds no keys.
Availability and observability
- The status page counts only real business traffic. Probe traffic is marked separately.
- A check job aggregates the success rate of the last 30 minutes every minute. An incident opens after 3 consecutive abnormal results with at least 10 samples and 2 failures. It recovers after 5 consecutive normal results.
- The admin console has curves of requests, failures, latency and time-to-first-byte percentiles in 2 to 30 minute buckets, and attempts and faults per channel.
Other
- Admin accounts support TOTP two-step verification.
- Invitation rebates and coupons.
Console

Usage log: model, four kinds of tokens, cost, duration, time to first byte and output per second for each request. The screenshot uses fixture data from a test database.

API Keys page: a key can be limited to a group, and auto routing can be turned on.

Lab: pick a model and chat or generate images directly in the console, billed to the wallet.
Timeline
| Time | Event |
|---|---|
| 2026-05-19 | First commit of the backend and front-end MVP |
| 2026-06 | Online payment added |
| 2026-06-22 | First commit of the desktop client |
| 2026-08 | The busiest month for commits, 101 in the backend; edge gateway (08-02), reserve-and-settle billing (08-28), TOTP (08-28) |
| 2026-09 | Mobile remote relay (09-30) |
| 2026-10 | First commits of the Android client (10-04) and iOS client (10-24); the shutdown plan began to be announced |
| 2026-11 | Service stopped on 11-20; backend, front end and command-line Agent open-sourced on 11-22, merged into one repository on 11-25 |
Scale
Operations data comes from the production database (read-only queries, as of 2026-11-19). The rest comes from the repository.
| Item | Number |
|---|---|
| Registered users | 3038 |
| Paying users | 699, with 3791 payment orders and 166,000 CNY paid in total |
| Calls | 8.78 million requests, 729 users made calls; about 960 billion input tokens (mostly cache hits) |
| Backend commits | 380, 295 of them mine |
| Backend source files | 1199 Go files, plus about 41,000 lines of test code |
| Desktop client | 543 commits, 47 version tags released |
| Command-line Agent | 345 commits, 44 version tags released |
| Supported API types | 15, including chat, embedding, image, speech, rerank, video and realtime |
| Stated on the public page | 67 models, 10 vendors (2026-09-27) |