by dengyie
Turn CNB cloud-workspace in-network AI into production OpenAI & Anthropic (Claude Code) APIs. Zero deps, v5.2 self-healing HA, quota CLI.
# Add to your Claude Code skills
git clone https://github.com/dengyie/cnb2apiGuides for using cli tools skills like cnb2api.
See how cnb2api compares with popular alternatives.
cnb2api is an open-source cli tools skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by dengyie. Turn CNB cloud-workspace in-network AI into production OpenAI & Anthropic (Claude Code) APIs. Zero deps, v5.2 self-healing HA, quota CLI. It has 58 GitHub stars.
cnb2api's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/dengyie/cnb2api" and add it to your Claude Code skills directory (see the Installation section above).
cnb2api is primarily written in JavaScript. It is open-source under dengyie on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other CLI Tools skills you can browse and compare side by side. Open the CLI Tools category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh cnb2api against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
Unlocks once the catalog security scan passes (runs nightly).
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
Turn CNB Cloud Workspace In-Network AI into a Production-Ready API Gateway
Get Up to 200M Free DeepSeek Tokens Monthly · Zero External Dependencies · 7×24h Self-Healing HA
OpenAI + Anthropic Dual Protocols · Zero-Config Claude Code Direct Connect · v5.2 Architecture · Terminal Quota Dashboard
English · 简体中文
TL;DR: CNB grants verified orgs 500 ~ 1,166 AI Credits and 1,600 compute core-hours monthly for free. Combined with CNB's 30x prompt caching discount, you can enjoy up to ~200 Million DeepSeek Tokens per month for free! However, the AI completion endpoint is strictly locked inside the workspace intranet with ephemeral pipeline tokens, while containers are recycled daily. cnb2api runs inside the workspace, converts it into a standard public API with zero dependencies, and leverages a v5.2 dual-watchdog self-healing architecture to deliver permanent domain access and 7×24 HA.
| Dimension | cnb2api (This Project) | Community Web NPC Scrapers | Direct Public Calling |
|---|---|---|---|
| Monthly Free Quota | Up to ~200M DeepSeek Tokens (1,166 Credits + Prompt Cache) | Unstable, easily rate-limited or banned | 0 (Blocked by network isolation) |
| Access Route | Official Workspace Intranet Endpoint | Web frontend anonymous NPC chat | Official Public Endpoint |
| Compliance & Account | 100% Compliant, consumes your org's quota | Violates ToS, scraping, ban risk | Cannot call (Network policy blocked) |
| Network Reachability | Intranet proxy + dynamic relay, Public stable access | Requires headless browser/proxy pools for CSRF | ❌ 403 Blocked by network policy |
| Auth Mechanism | Ephemeral CNB_TOKEN via pipeline (Zero leakage) |
Web cookies / session scraping | ❌ Personal tokens 403 (Pipeline only) |
| Protocol Support | OpenAI + Anthropic Dual Protocol Stack | Partial OpenAI text-only imitation | None |
| Claude Code Direct | Native Direct Connect (with 11128 workaround) | ❌ Unsupported (no tools / blocked) | None |
| Native Tool Calling | Full pass-through (incremental streaming merge) | ❌ Unsupported | None |
| External Dependencies | Zero Dependencies (Node.js 22+ built-in, instant boot) | Heavy dependencies (Chromium, Puppeteer) | None |
| High Availability | v5.2 Dual-Watchdog Self-Healing (Internal cron + watchdog) | Single point of failure on UI changes | None |
| Quota Transparency | Built-in Terminal CLI Dashboard + /usage metrics |
Black-box, no usage tracking | Only visible deep in web console |
/v1/chat/completions and /v1/models, supporting SSE streaming and faithful non-streaming aggregation (reconstructing usage, exact credit costs, incremental tool_calls, and finish_reason)./v1/messages and /v1/messages/count_tokens, enabling Claude Code CLI direct connection with full support for thinking blocks, tool calling, and event streams.CNB_TOKENs minted on demand and destroyed on completion.start.sh registers the new dynamic subdomain to your relay (/ops/register), which hot-reloads nginx upstream configurations. Client URLs and keys stay permanent. Full recovery takes ~2m 13s.cnb-watchdog.sh) detects stalled states and silently triggers fallback OpenAPI starts with cooldown protection.fetch, ReadableStream, crypto.timingSafeEqual, node:test). Zero npm install, instant cold starts.cnb2api-quota CLI: One-command ANSI progress bar dashboard showing AI credits, dev core-hours, CI core-hours, and in-flight amounts directly from the official charge API. Supports --json and --line.GET /usage accounting endpoint grouped by boot generation with UTC+8 daily rollups.Client (OpenAI Client / Claude Code / API Gateway)
│ https://ai.example.com/v1 (Fixed domain, self-hosted Nginx relay)
▼
https://<dynamic-subdomain>-9001.cnb.run (CNB port-proxy, auto-synced via /ops/register on boot)
│
▼
node src/server.mjs (Workspace port 9001, cnb2api reverse proxy)
│ Bearer CNB_TOKEN (Auto-minted by CNB pipeline, internal network)
▼
https://api.cnb.cool/<org>/<repo>/-/ai/chat/completions (Official AI core endpoint)
The workspace is treated as cattle, not a pet:
*/5 * * * *) checks workspace health and calls workspace/start if stopped.deploy/start.sh POSTs the newly assigned subdomain to /ops/register on your relay, which reloads Nginx.cnb-watchdog.sh) monitors the fixed domain to guard against CI platform cron dormancy.Three simple steps, only one API key to configure:
.cnb.yml, set your custom PROXY_KEY in the env: block (e.g. openssl rand -hex 24).PROXY_URI=https://<subdomain>-9001.cnb.run — ready to use!💡 Need a permanent domain? Set up a simple Nginx reverse proxy on your VPS with
/ops/register. See the Full Setup Guide (docs/SETUP.md).
ANTHROPIC_BASE_URL=https://ai.example.com \
ANTHROPIC_AUTH_TOKEN=your-proxy-key \
ANTHROPIC_MODEL=deepseek-v4-flash \
claude -p "Hello! Introduce yourself."
Point BaseURL to https://ai.example.com/v1 and set API Key to PROXY_KEY:
deepseek-v4-flash)curl https://ai.example.com/v1/chat/completions \
-H "Authorization: Bearer your-proxy-key" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-v4-flash","messages":[{"role":"user","content":"hi"}],"stream":false}'
Real production billing data measured over months of live operation (not marketing hype):
| Resource Allowance | Free Monthly Quota | Cost & Capacity Notes |
|---|---|---|
| AI Credits | Base 500, up to 1,166 after hello-cnb quest | Every response reports exact credit in usage. Combined with Prompt Cache, delivers ~200M DeepSeek Tokens/month. |
| Compute Core-Hours | 1,600 core-hours (shared dev + CI pool) | A runner.cpus: 2 workspace running 24/7 for 30 days costs 1,440 core-hours (safely within the 1,600 pool). No need to stop the proxy. |
💡 The Math Behind 200M Free Tokens/Month:
- Base Upstream Rate: Live measurements on
deepseek-v4-flashshow an uncached 9,000-token request costs ~0.39 credit (approx 23,000 tokens / credit).- Official Prompt Cache 30x Discount: Once prompt prefixes hit CNB's prompt cache, cost drops to ~0.01 credit, slashing cost to 1/30 of base price (~700,000 tokens / credit).
- Real-World Scenarios: In coding assistants, Claude Code, and multi-turn Agent conversations with long system prompts and history reuse, cache hit rates typically sit at 80%~95% (assuming a realistic 90% cache hit rate): $$\text{Blended Cost} = 10% \times 1 + 90% \times \frac{1}{30} \approx 13% \text{ base cost} \implies \approx 177,000\text{ tokens / credit}$$ $$\text{Monthly Total} = 1,166\text{ credits} \times 177,000\text{ tokens} \approx \mathbf{206\text{ Million tokens / month}}$$
- Run
npm run quotaanytime in your terminal to inspect your live remaining credits and consumption.
Check your quota and usage straight from the terminal, even if the proxy workspace is offline:
npm run quota # or: npx cnb2api-quota
◆ CNB quota your-org
Credits ███████▋─────────────────── 32% 320.0 / 1,000.0 cr
Dev ██████▏───────────────────── 25% 406.4 / 1,600.0 core-h
CI █▋────────────────────────── 8% 13.0 / 160.0 core-h
in-fligh