Contents
Project
- Name: self-hosted AI API gateway
- Status: partly functional, development stopped
- Started: August 2026
- Stack: New API, Docker, Nginx, Cloudflare, acme.sh, 1Panel, CC Switch
- Nature: personal self-hosted experiment, never a public commercial service
- Article: Henry
I wanted one API address for several model providers. DeepSeek used one key, Xiaomi MiMo used another, and each client wanted its own provider, URL, and model configuration.
I did not want to repeat that setup in Codex, Chatbox, and Cherry Studio every time I changed models.
The idea looked standard: maintain one endpoint and one token, then route requests to different providers. The difficult part was never entering a few keys. It was protocol behavior, tool calling, client compatibility, and maintenance.
The problem was not “calling a model”
The real problem was fragmented entry points:
- Codex uses the Responses protocol and sends its own tool definitions.
- Most chat clients use Chat Completions.
- Providers differ in reasoning fields, tool-call formats, and context limits.
- A configuration that works in one client can fail in another.
The intended structure was:
Clients → OpenAI-compatible gateway → DeepSeek / MiMo / other providers
Clients would know only the gateway. Authentication, routing, model mapping, and usage records would live in one place.
Why New API
Commercial aggregators already exist, but self-hosting offered direct control over channels, keys, tokens, quotas, and model mapping. New API was open source and supported several upstream API formats.
I ran New API in Docker behind Nginx, put Cloudflare in front, and renewed certificates with acme.sh. A new subdomain avoided disturbing existing services.
What worked
The gateway provided one OpenAI-compatible entry point. DeepSeek models completed normal chat and reasoning tests through /v1/responses. New API’s admin panel made channels and tokens manageable. The Cloudflare → Nginx → Docker structure was reusable. I also kept scripts to switch Codex to the gateway and restore its original configuration, with automatic backups.
Where it broke
Responses is not another name for Chat Completions. Request structures, streaming events, tool calls, and reasoning fields differ. Translating between them demands preserving semantics, not just status codes.
I first placed CC Switch before New API. With two translation layers, reasoning fields were lost and multi-turn requests returned 400. Connecting Codex directly to New API made DeepSeek stable again.
Every additional proxy layer adds another place where fields can disappear.
Xiaomi MiMo worked in ordinary Chat Completions clients. Codex, however, sends custom tools such as shell, apply_patch, and web search. MiMo’s upstream API did not accept those tool types. Testing with the provider’s own integration produced the same result, so the limitation was not a New API setting.
The final state was honest:
- DeepSeek worked in Codex.
- MiMo worked in ordinary chat clients.
- MiMo could not act as a complete coding agent in Codex.
Small operational problems
Cloudflare DNS produced an intermittent NXDOMAIN for a subdomain even while the edge proxy could reach it. Recreating the hostname eventually solved it. Client model lists also fell back to internal names when catalog metadata was missing.
I was maintaining Docker, a database, Nginx, DNS rules, certificates, upstream compatibility, model catalogs, client configuration, and logs for only two or three models. The operational burden outweighed the benefit.
Why I stopped
Direct DeepSeek was stable for my main use. Commercial aggregators already handled broad compatibility. A self-hosted gateway becomes worthwhile with shared quotas across projects, internal billing, strict data-path requirements, or a commitment to long-term compatibility work.
My scale did not justify that commitment.
The final setup is deliberately simple:
Codex ───── DeepSeek
Chat clients ─ Xiaomi or other models
What the failure taught me
API compatibility is not behavioral compatibility. Returning 200 is not enough; a complete multi-step client task has to finish.
Do not stack translation layers for the sake of unification. If a client can connect directly, another proxy may only add risk.
Test the hardest workflow first. Ordinary chat was easy. Codex tool calls exposed the real boundary.
Self-hosting is not automatically cheaper. Open-source licenses remove a fee, not server time, certificates, monitoring, or incident response.
Stopping a project that looks like it should continue can be the more correct engineering decision.
Open-source and third-party notices
New API
- Maintainer: QuantumNous and contributors
- Repository: github.com/QuantumNous/new-api
- License: AGPL-3.0
- Use: self-hosted gateway, channel and token management, protocol compatibility
- This project used Docker without modifying New API source and is not an official New API distribution.
One API
- Author: songquanpeng and contributors
- Repository: github.com/songquanpeng/one-api
- License: MIT
- Related predecessor project; not directly deployed here.
CC Switch
- Author: farion1231 and contributors
- Repository: github.com/farion1231/cc-switch
- License: MIT
- Used briefly for provider configuration and later removed from the request path.
Nginx
- nginx.org
- License: BSD-2-Clause
- Use: reverse proxy and HTTPS entry point.
acme.sh
- github.com/acmesh-official/acme.sh
- License: GPL-3.0
- Use: certificate issuance and renewal.
1Panel
- github.com/1Panel-dev/1Panel
- License: GPL-3.0
- Use: server and Nginx management.
Services
DeepSeek API and Xiaomi MiMo API are third-party commercial services. Cloudflare provides DNS and proxying. Docker runs the gateway container. This article contains no real API keys, admin passwords, or server credentials. The personal scripts are not currently published as an open-source project.
Comments 0
Leave a thought or add to the conversation. Comments appear after moderation.
Loading comments…
Be the first to leave a thought.