From Beego to TokenHub: Why This Open Source Veteran Built an Enterprise AI Gateway
The author reflects on their open source journey from the Beego framework to TokenHub, explaining why they created another AI gateway despite existing solutions, focusing on enterprise needs like identity management, cost attribution, audit logs, and Apache 2.0 licensing for commercial freedom.
The article traces the author's open source path from Beego, a Go web framework, to TokenHub, an AI API gateway. Beego taught three core lessons: releasing code is only the beginning — real open source requires documentation, community engagement, and long-term maintenance; technical choices become commitments to users who depend on the project in production; and a successful project eventually outgrows its creator, thriving through community contributions.
Parallels Between Web and AI Eras
Just as Beego organized scattered web development complexities (routing, ORM, sessions) into a cohesive framework, TokenHub addresses today's AI fragmentation: multiple model providers, subscription accounts, API keys, token costs, and audit requirements. The author argues that enterprises need a unified platform to manage identity, project keys, provider routing, quotas, cost centers, and audit logs — not just request forwarding.
Why Apache 2.0
TokenHub adopts Apache License 2.0, the same as Beego. The author prefers permissive licenses because they allow enterprises to download, modify, deploy commercially, and integrate privately without forcing disclosure of proprietary code. This is critical for AI gateways that touch identity systems, cost centers, and internal models. While acknowledging the value of copyleft licenses (GPL, AGPL, LGPL), the author notes that strong copyleft and dual-licensing models increase legal evaluation overhead for enterprise adoption. Apache 2.0 aims to let teams deploy confidently without a license-risk review.
Positioning Against Existing Projects
The author compares TokenHub with several open source AI gateways:
LiteLLM : Strong for developer teams needing multi-model SDKs, protocol adaptation, and failover. TokenHub adds an enterprise workspace: employee identity, project keys, cost centers, request logs, and role-based governance in one system.
Portkey : Offers enterprise features, observability, caching, and managed services. TokenHub prioritizes Apache 2.0, self-hosting, and private customization within compliance boundaries.
Higress : A cloud-native API gateway built on Istio/Envoy with deep Kubernetes, Ingress, and Wasm plugin expertise. TokenHub does not aim to replace such general traffic gateways but focuses on a lighter internal AI token platform.
OneAPI / New API : Multi-provider relay and billing/operations platforms suited for selling quotas to external users. TokenHub targets internal enterprise governance — making AI a controllable internal capability.
Sub2API : Converts subscription resources (Claude, Codex, Gemini CLI) into APIs for team sharing. TokenHub supports such accounts as one provider type but centers on who manages them, which identity uses them, project attribution, cost allocation, and auditability.
The author emphasizes that these projects solve different problems; TokenHub's differentiation lies in unifying enterprise relationships (identity, projects, costs, audit) behind the forwarding layer.
Enterprise-Grade Requirements Beyond the Interface
TokenHub addresses questions that arise outside the request/response path: who can use models; role-based workspaces for employees, team leads, and admins; per-project key restrictions (models, quotas, concurrency, source); multi-provider routing with weights, priority, health checks, cooldown, and fallback; token-level cost attribution to person, team, project, and cost center; security audit trails of requests, routing hits, and policy changes; and lifecycle synchronization with organizational changes (onboarding, transfers, offboarding).
Features include SSO, OAuth/OIDC, RBAC, project keys, quota and concurrency controls, request logs, backend audit, and private deployment. Models can come from OpenAI, Anthropic, Gemini, domestic providers, or local models, but identity, entry points, costs, and evidence chains remain on the enterprise's own platform.
Philosophy: Not Proving Others Wrong
The author rejects the trap of disparaging existing projects. Open source is not a single-answer test; each project stems from distinct pain points. TokenHub's clarity comes from stating its own choices: Apache 2.0, private-deployment-first, identity/project/cost/audit before forwarding, serving internal platforms rather than token resale. With clear positioning, comparison shifts from "more features" to "better fit for this scenario."
If you need quick multi-model access, LiteLLM fits; for large-scale Kubernetes AI traffic, evaluate Higress; for multi-channel relay and billing ops, New API has community maturity; for subscription-to-API conversion, Sub2API is direct. If you want an enterprise-owned AI unified entry with controllable accounts, traceable calls, attributable costs, revocable permissions, and code free for long-term commercial use and modification, TokenHub aims to be that option.
Continuing the Open Source Commitment
The author views open source as a collaboration model, not a marketing label or user-acquisition tactic. From university to now, the community has provided knowledge, tools, partners, and opportunities. Beego was the Web-era contribution; TokenHub is the AI-era one. The technical problems changed — from faster enterprise app development to safer, stable, controllable enterprise AI use — but the open source principles remain: permissive licensing, user autonomy, and valuable infrastructure open for collective building. The project is at github.com/astaxie/TokenHub.
Code Reference from Source
The article includes a code-like reference in a heading: 企业级 AI 网关,不能只有一条 / v1 接口 (Enterprise-grade AI gateway cannot have only a single / v1 interface).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
