← all repositories
astaxie/TokenHub

AI gateway that separates chatters from bean counters

TokenHub exists because dropping a shared OpenAI key into a Slack channel does not scale past one invoice and zero accountability.

557 stars TypeScript Inference · ServingLLMOps · Eval
TokenHub
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

TokenHub sits between your applications and upstream AI providers—OpenAI, Anthropic, Gemini, DeepSeek, Ollama, or anything with an OpenAI-compatible API—and adds an enterprise control plane. It exposes standard /v1/chat/completions and /v1/embeddings endpoints, but wraps them in project-scoped API keys, usage quotas, concurrency limits, and request logging. The web console splits cleanly into three workspaces: users see models and personal usage, team leaders manage projects and cost attribution, and administrators configure providers, routing policies, RBAC, and identity sources.

The interesting bit

The backend is Go, the frontend is Next.js, and the default deployment is SQLite-first for a single box. When you need scale, the same binaries run behind Nginx with a remote PostgreSQL database handling OAuth sessions, quota buckets, audit trails, and cluster locks. Backend replicas coordinate using PostgreSQL clock time rather than host clocks to avoid lease skew, and the model catalog synchronizes idempotently across instances on startup.

Key highlights

  • OpenAI-compatible proxy with support for Azure OpenAI, Anthropic, Gemini, DeepSeek, Qwen, vLLM, and custom upstreams
  • Routing policies with priority, weighted load balancing, failover order, and health diagnostics
  • Project-scoped API keys with team ownership, member permissions, quotas, and concurrency controls
  • Usage analytics and request logs attributed to user, project, team, model, and cost center
  • Enterprise identity via OAuth/OIDC, RBAC, and audit trails
  • SQLite-first private deployment; horizontal scaling via Docker Compose with PostgreSQL and Nginx load balancing
  • Console localized in English, Chinese, and Japanese

Verdict

Teams that need to share AI model access across multiple projects and actually track who spent what should look here. Solo developers who just need a quick OpenAI proxy will find the role-based overhead excessive.

Frequently asked

What is astaxie/TokenHub?
TokenHub exists because dropping a shared OpenAI key into a Slack channel does not scale past one invoice and zero accountability.
Is TokenHub open source?
Yes — astaxie/TokenHub is open source, released under the Apache-2.0 license.
What language is TokenHub written in?
astaxie/TokenHub is primarily written in TypeScript.
How popular is TokenHub?
astaxie/TokenHub has 557 stars on GitHub.
Where can I find TokenHub?
astaxie/TokenHub is on GitHub at https://github.com/astaxie/TokenHub.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.