TokenHub

astaxieApache-2.0活跃维护

企业级私有 AI 网关,统一接入和治理各家大模型,让每次调用都可控、可追踪、可归属。

TokenHub gives enterprises a private gateway to unify AI model access and governance, making every request controllable, traceable, and attributable.

v0.10.0发布于 2026-10-20 05:34 UTC1,430star +3 / 7 天196fork同步于 2026-11-10 11:48 UTC

怎么上手

由 README 提炼,执行前请确认
cp deploy/.env.example deploy/.env
./deploy/install.sh
硬件要求按 README 说明

README 未说明显存或 GPU 要求;提供 Linux systemd 原生安装与 Docker Compose 两种部署方式,默认使用 SQLite,多实例部署可改用远程 PostgreSQL。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

企业级 AI 模型统一网关,让每次模型调用可控、可追溯、可归因

企业级私有 AI 网关,统一接入和治理各家大模型,让每次调用都可控、可追踪、可归属。

核心能力

  • 按项目与团队分配密钥,统一管控配额与并发
  • 按场景、成本、健康度配置路由与故障转移策略
  • 用量与请求日志归因到用户、项目、团队和成本中心
  • 对比内部用量与供应商账单,核对实际 AI 成本
  • 兼容 OpenAI 与 Anthropic Messages 接口,支持嵌入、重排与图像生成

容易踩的坑

部署前必须把 deploy/.env 里所有 change-me 值替换为强密钥;Docker 部署初始 admin 密码取自 TOKENHUB_BOOTSTRAP_ADMIN_PASSWORD,原生安装密码只由安装脚本打印一次;默认控制台在 3000 端口、后端 API 在 8080 端口,需确认端口未被占用。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.10.0
  1. v0.10.0TokenHub v0.10.0最新正式版2026-10-20 · 2026-10-20 05:34 UTC

    TokenHub v0.10.0

    TokenHub v0.10.0 brings image, audio, and video workflows into the enterprise AI gateway, adds multiple upstream keys per Provider, simplifies daily administration, and improves usage reporting, billing, and resource control.

    This release covers all 172 commits and 20 merged pull requests since v0.9.0, including contributor updates and release-version synchronization. The complete PR and commit inventories are included below.

    Highlights

    • One gateway for text and media: published models can use image generation/editing/variations, speech synthesis, transcription, translation, and video workflows with shared authentication, model access, quotas, policies, and accounting.
    • Durable asynchronous video and image tasks: submit through /v1/videos/generations or supported Images routes and poll /v1/tasks/{task_id} with opaque, owner-bound task IDs that survive restarts and stay pinned to the original provider account.
    • Multiple API keys per Provider: rotate and manage upstream keys with independent priority, weight, RPM, TPM, and concurrency limits while retaining resource routing and failover.
    • Simpler operations: searchable provider onboarding, compact model and route management, background provider monitoring, and Today / 7 days / 30 days / All usage reports.
    • Practical cost and quota controls: independent default allowances for every user, configurable daily/monthly quota timezones, audio-second billing, and statement reporting in USD, CNY, JPY, or RUB using manual rates.
    • Bounded resource use: SQL-based usage aggregation, separate SQLite critical/analytics readers, smaller audit snapshots, and configurable application memory budgets.

    Detailed changes

    Media APIs, transcription, and retrieval

    • Extend ordinary published upstream models to image generation, JSON/multipart edits, variations, speech, transcription, and translation. Preserve supported masks, repeated multipart fields, vendor options, multiple results, binary audio, subtitles, and large numeric identifiers. Native Gemini media retains generation configuration, inline content, thought signatures, and supported SSE payloads. (#361, #390)
    • Support documented provider-specific video, music, lyrics, voice upload/clone, and drawing workflows through existing Chat/Responses surfaces. Media generation and task queries bypass response caches; background Responses retain their local job ID and expose validated vendor response IDs separately. (#361)
    • Add POST /v1/videos/generations and GET /v1/tasks/{task_id}. Recognized Images/Videos receipts receive opaque gateway handles backed by encrypted, persistent bindings. Polling validates owner, model access, and the original resource/account; supported source/draft/extension references are resolved under the same restrictions. Polling consumes request quota without charging generation tokens again. (#392)
    • Apply text policies, request/provider/response/stream hooks, guarded outbound transport, authorization, quotas, and usage attribution across media workflows. Validate JSON, SSE completion/error envelopes, binary output, MIME types, Base64, and size limits. Ambiguous generation failures do not cause automatic duplicate submissions. Preserve valid usage after delivery or hook failures and redact credentials without corrupting task/media fields. (#361, #390, #392)
    • Complete native multipart transcription capability and endpoint checks. Validate file signatures and upload limits after hooks and safety masking, accept valid MP4/M4A padding, and keep uploaded media and transcript text out of direct-media audit/trace payloads. (#390)
    • Add fractional audio-second metering with independent public-model and provider rates via metadata.audio_price_usd_per_second. Retain duration and independent token/cache/reasoning details through streams, quota settlement, durable evidence, statements, and failed delivery. Missing costs remain unknown; duration is not converte
  2. v0.9.0TokenHub v0.9.02026-09-25 · 2026-09-25 16:34 UTC
    查看更新说明

    Highlights

    TokenHub v0.9.0 upgrades the gateway from a chat-focused proxy into a broader enterprise AI gateway for retrieval, semantic routing, governed provider integrations, and production Kubernetes operations. This release covers every commit from v0.8.0 (2026-09-09) through v0.9.0 (2026-09-26): 134 commits, including the release-version synchronization commit.

    • Embeddings and rerank: add OpenAI-compatible /v1/embeddings and /v1/rerank routes, dense-vector contracts, governed text reranking, provider inventory admission, cache and failover handling, model-family discovery, and stable route/resource enforcement.
    • Semantic routing: add opt-in Jev model selection with configurable policies, candidate ranking, budget compatibility, fallback, continuation review, and Responses support, with matching admin controls and documentation.
    • TypeSafe / System One: add a native provider integration with bounded JSON parsing, decision and score-legend validation, native request IDs, usage/error preservation, cancellation, sensitive-header redaction, and SDK-compatible request/response handling.
    • Provider coverage: expose Dify apps as chat-completion models; restore GPT-6 Astra discovery and add GPT-6 Sol/Luna discovery; list the complete catalog inventory; add Alibaba rerank catalog generation; support native Codex image edits; and improve Gemini, private-upstream, API-key wizard, and provider-network behavior.
    • Retrieval metering and billing: price search/retrieval units independently from tokens, preserve tenant/native/free prices, bind usage and cache accounting to effective routes, keep redaction and upstream credentials safe, and expose clearer localized retrieval pricing in the console.
    • Deployment and operations: ship a production Helm chart, safe non-overlapping rollouts, instance-scoped image-job recovery, shared image storage and ExternalSecret support, stronger bootstrap and secret handling, database ping diagnostics, and migration compatibility for historical metering ledgers.
    • Admin console and localization: add comprehensive Russian Gateway and admin localization with locale-aware plurals, counts, pagination and currency; improve billing, audit, provider, model-catalog and API-key workflows; and refresh catalog labels and UI layouts.

    Detailed changes

    Embeddings, rerank, and retrieval

    • Add provider-neutral embedding contracts for dimensions, encoding formats, token limits, model identity, deployment spaces, admission checks, cache keys, and route input immutability.
    • Add governed text reranking across providers with /v1/rerank, ranking-order validation, cache-key echo enforcement, effective-route usage attribution, redacted request handling, credential-safe load tests, and legacy catalog-type normalization.
    • Validate inventory and route contracts before publication and execution; reject unverified deployment spaces, invalid initial route sets, unsupported model families, undeclared client/cache contracts, and inconsistent resource routes.
    • Add retrieval pricing controls to model creation and preserve explicit free/native prices through save, reload, tenant-rate repricing, and statement generation.
    • Track retrieval usage units and search units separately from token usage, reconcile resource publication, and distinguish free prices from unknown prices in the admin console.

    Jev semantic routing

    • Add opt-in Jev semantic model selection and make Jev a configurable routing strategy with administrator policy controls.
    • Require matching chat output-budget support, retain budgets when candidates are edited, refresh edited candidates, enforce admission and continuation review rules, and preserve Responses continuation behavior.
    • Keep routing, cache, usage, and billing tied to the effective route and maintain compatibility with existing priority and failover strategies.

    TypeSafe / System One

    • Add the native TypeSafe / System One provider integration and SD
  3. v0.8.02026-09-09 · 2026-09-09 03:51 UTC
    查看更新说明

    Highlights

    TokenHub v0.8.0 brings a plugin platform and management overhaul, richer pricing and cost statements, expanded model catalogs, and fixes across gateway execution, deployment, and the admin console. This release covers every change from v0.7.0 to v0.8.0, including the complete commit inventory below.

    • Plugin API v2 and management: inspectable built-in Provider plugins, declarative admin contributions, interface templates, package installation and updates, rollback, persistent lifecycle state, and verified Marketplace discovery.
    • Gateway and Provider architecture: manifest-driven Provider policies and resource actions, consistent scoped gateway stages, protocol-aware admission, streaming transforms, and preserved legacy Provider compatibility.
    • Billing and FinOps: weekday/time-zone pricing windows, cache-write pricing tiers, immutable exact shadow rate cards and exchange rates, request/attempt evidence, and separate customer, Provider, and estimated-margin statements with CSV export.
    • Models and connectivity: StepFun direct and Step Plan presets, twelve curated StepFun models, GPT-6 Astra catalog support, model-aware reasoning controls, and supported local/private upstream configuration.
    • Console and operations: clearer plugin installation, lifecycle, settings, and error states; localized catalog errors and model counts; persistent plugin volumes; and expanded acceptance, migration, and release packaging checks.

    External executable plugins are not operational in v0.8.0. Packages with entry.backend.command are rejected before launch and recorded as failed_startup, because TokenHub cannot yet enforce the required host-level process, network, and resource isolation. They remain installed and inspectable, but register no Provider adapter, gateway hook, background job, or management action. In-process built-ins and supported declarative presentation packages remain available. The DevKit exercises the future command contract locally; its examples are fixtures, not production integrations.

    Detailed changes

    Plugin platform, lifecycle, and distribution

    • Introduce Plugin API v2 manifests, compatibility and dependency checks, capability declarations, permissions, trust policies, action input/output schemas, and separate installation, activation, startup, fallback, and rollback state.
    • Represent the built-in Provider catalog as generated, inspectable plugin packages. Derive Provider types, labels, categories, default URLs, authentication modes, credentials, resource types, route protocols, managed headers, discovery behavior, session affinity, reasoning controls, error handling, and image policies from declarations.
    • Route Provider lifecycle operations through declared actions, including OAuth start/callback exchange, credential refresh, reauthorization, account probes, model discovery/import, quota reads/resets/monitoring, and image capability configuration. Preserve legacy aliases, routes, resources, quota state, and usage/audit compatibility during migration.
    • Add verified ZIP and URL installation, file inspection, updates, uninstall, enable/disable, rollback, permission-diff previews, and explicit startup quarantine. Supported declarative changes are reevaluated without restarting the service; stale restart markers are cleared after application.
    • Persist built-in Provider, Admin UI, and interface-template lifecycle state across restarts. Disabled or failed built-ins remain inspectable while publishing no active UI contributions, actions, or scheduled jobs; re-enabling restores supported operation.
    • Preserve neighboring plugin directories and the current package during updates. Rejected checksum, signature, dependency, or validation checks retain the existing rollback backup, including legacy installation layouts and plugin IDs ending in .previous.
    • Add Marketplace index validation, channel browsing, compatible release selection, strict SemVe
  4. v0.7.02026-08-25 · 2026-08-25 02:42 UTC
    查看更新说明

    Highlights

    • Added the forward-only database evolution system: migration ledger, dry-run contract preflight, frozen SQLite/PostgreSQL baselines, repair paths, instance heartbeats, rollback compatibility checks, managed upgrade preflight, and auto-rollback support for failed boots.
    • Expanded quota and billing controls with aggregate user limits, owner-safe quota history, atomic image admission accounting, granular pricing controls, Redis admission rollback hardening, and extracted billing domain, persistence, and adapter modules.
    • Hardened administrator security across OAuth, password reset, CSP, session bounds, API key mutation authorization, provider/resource credential redaction, alert delivery secrets, image job access, forwarded headers, and provider egress proxy validation.
    • Improved provider and gateway compatibility with configurable global egress proxy settings, preserved explicit Codex background nulls, max_completion_tokens support across adapters, implicit-TLS/STARTTLS SMTP encryption modes, and safer legacy provider refresh routing.
    • Upgraded the admin console with per-key usage details, daily usage visibility, improved API key usage charts, locale-aware number formatting, and a redesigned localized login homepage.
    • Added OpenAPI gateway reference documentation, refreshed token governance positioning, restart-safe production bootstrap checks, and stream quality observability for time-to-first-byte and interruptions.
    • Continued modularization by moving billing, reconciliation, and method-routed server responsibilities into smaller domain-oriented modules with expanded regression coverage.

    Release artifacts

    • Linux native archives for amd64 and arm64, plus checksums.txt, are built and attached by the release workflow.
    • Container images are published as ghcr.io/astaxie/tokenhub-backend:0.7.0, :0.7, and :latest.
    • The frontend and SDK smoke-test package metadata were bumped to 0.7.0 in chore(release): prepare v0.7.0.

    All merged PRs since v0.6.0

    Features and enhancements

    • feat(db): add forward-only database evolution with migration ledger (#265) by @deepjerry-ai
    • feat(quota): enforce aggregate user limits (#263) by @astaxie
    • feat(api-keys): add per-key usage details (#276) by @imaben
    • feat(admin): add daily usage dashboard (#277) by @astaxie
    • feat(provider): add configurable global egress proxy (#273) by @deepjerry-ai
    • feat(frontend): improve API key usage page charts and layout (#279) by @imaben
    • feat(billing): add granular pricing controls (#283) by @astaxie
    • feat(docs): add OpenAPI gateway reference (#284) by @astaxie
    • feat(notification): support implicit-TLS SMTP email channels (#271) by @excniesNIED
    • feat(observability): stream time-to-first-byte and interruption metrics (#141) by @coldbrewtea
    • feat(frontend): redesign login homepage (#287) by @astaxie

    Fixes and hardening

    • fix(store): correct quota accounting under bad usage and clock skew (#261) by @debin-ge
    • fix(security): harden administrator authentication and secrets (#257) by @deepjerry-ai
    • fix(codex): omit unset background probe parameter (#269) by @Mr0bean
    • fix(deploy): make production bootstrap restart-safe (#281) by @legendtkl
    • fix(api-keys): restrict assigned key mutations ([#282](ht
  5. v0.6.02026-08-17 · 2026-08-17 02:27 UTC
    查看更新说明

    Highlights

    • Expanded gateway compatibility with Claude reasoning translation, Codex request fingerprint convergence and metadata preservation, Codex image capability and token renewal, DeepSeek V4 Pro Responses routing, durable background Responses execution, Anthropic bearer authentication and streaming cache usage, multimodal playground inputs, and custom upstream request headers.
    • Added project-scoped content security guardrails, guardrail enforcement for /v1/responses/compact, masked-content model detection, configurable request body limits, provider URL SSRF protections, configurable synthetic DNS ranges, and safer API-key search and upgrade behavior.
    • Added Kronk local inference support, Qwen3.6 and GLM-5.3 catalog entries, upstream catalog refresh, model protocol visibility and validation, editable model display names, request-log filters, catalog refresh error reporting, route preservation, and provider credential probing.
    • Reworked HTTP method routing across gateway, system, provider, model, routing, project, identity, API-key, admin utility, governance, operation, and resource endpoints, with expanded routing contract coverage.
    • Added reproducible gateway benchmarks and broad hot-path improvements: SQL-backed usage and quota aggregation, removal of usage-breakdown N+1 queries, batched route-candidate lookups, precomputed rendezvous scores, API-key ID lookups, last-used write throttling, gateway lock reduction, stream-frame probing, model-label caching, and a larger upstream idle connection pool.
    • Improved deployment and project maintenance with image-worker concurrency configuration, localized contributor automation, frontend lint/test/browser quality gates, provider and usage test isolation, and updated provider documentation and showcase content.

    Release artifacts

    • Linux native archives for amd64 and arm64, plus checksums.txt, are built and attached by the release workflow.
    • Container images are published as ghcr.io/astaxie/tokenhub-backend:0.6.0, :0.6, and :latest.

    All merged PRs since v0.5.0

    Features and enhancements

    • feat(server): enforce configurable JSON request body limits (#144) by @samz406
    • feat: add project-scoped content security guardrails (#174) by @deepjerry-ai
    • feat(responses): add durable background execution (#193) by @legendtkl
    • feat(providers): support bearer auth for anthropic (#137) by @CLukeLi
    • feat(playground): support multimodal image inputs (#173) by @imaben
    • feat(providers): add custom upstream request headers (#191) by @astaxie
    • feat(models): add Qwen3.6 catalog entries (#199) by @deepjerry-ai
    • feat(provider): add Kronk local inference support (#203) by @astaxie
    • feat(deepseek): enable responses for v4 pro (#202) by @deepjerry-ai
    • feat(catalog): fetch upstream catalog on refresh (#218) by @astaxie
    • feat(codex): renew tokens and configure image capability (#192) by @Mr0bean
    • feat(catalog): add GLM-5.3 coding plan support (#232) by @deepjerry-ai
    • feat(audit): filter request logs by time and model (#242) by @Mr0bean
    • feat(models): show supported model protocols (#236) by @Mr0bean
    • feat(models): add editable display names (#240) by @Mr0bean

    Fixes and hardening

    • fix(codex): filter unsupporte

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    ❤️ Sponsors

    Want to appear here?

    Enterprise Token Governance

    TokenHub gives enterprises a governance layer for the AI model lifecycle, from provider access and project keys to routing policy, usage attribution, budget control, and bill reconciliation.

    The core problem is what happens after every team, application, and workflow starts consuming more models and more tokens. TokenHub puts governance controls in front of every model call:

    • Model routing: choose the right model by scenario, cost, performance, health, and fallback policy.
    • Permission management: allocate and control token access across people, teams, projects, and applications.
    • Token savings: reduce AI spend through caching, model selection, quotas, and call strategy.
    • Provider reconciliation: compare internal usage with provider bills so finance, platform, and business teams can explain actual AI cost.

    Why TokenHub

    Many open source AI gateways focus on provider fan-out: one endpoint that can call many upstreams. That helps developers connect models, but it does not solve the enterprise operating problem by itself. TokenHub is built around the missing governance layer:

    • Token distribution is managed by project and team instead of by copying raw provider keys into every application.
    • Model access, routing, and fallback are policy decisions that administrators can change without rewriting client code.
    • Bills and request history can be compared against internal ownership so finance, platform, and business teams can explain AI spend.
    • User, team leader, and administrator workspaces keep daily usage, approval, cost attribution, and platform operations separated by responsibility.

    Screenshots

    Designed Around Three Roles

    TokenHub separates everyday model usage, team governance, and platform administration so enterprise users see the workflows that match their responsibility.

    RoleWorkspace FocusGuide
    UserFind available models, create project-scoped API keys, call the model API, and review personal usageUser Guide
    Team LeaderManage project spaces, project members, project keys, team reports, and project cost attributionTeam Leader Guide
    AdministratorConfigure providers, model catalog, routing policies, identity sources, RBAC, audit, and cost controlsAdministrator Guide

    Platform Capabilities

    • Project-scoped key management with team ownership, member permissions, quotas, and concurrency controls.
    • Model catalog and routing policies with priority, weight, failover order, scenario-aware selection, and route health diagnostics.
    • Usage analytics and request logs attributed to user, project, team, model, and cost center.
    • Cost controls for token budgets, provider spend comparison, model choice, and future caching-driven savings.
    • Identity source configuration for OAuth/OIDC enterprise sign-in, plus RBAC and audit trails.
    • OpenAI-compatible model APIs: /v1/chat/completions, /v1/responses, /v1/embeddings; Anthropic Messages APIs: /v1/messages, /v1/messages/count_tokens.
    • Text retrieval: dense embeddings through /v1/embeddings and document reranking through /v1/rerank, with provider-specific protocol configuration.
    • OpenAI-compatible image generation and reference-image editing through /v1/images/generations and /v1/images/edits, with asynchronous jobs and server-side image retention.
    • Clean console with compact role-aware navigation, global search, light/dark mode, and split-view API documentation.
    • SQLite-first private deployment with native systemd and Docker Compose options.
    • PostgreSQL supports multi-instance deployments: share state through remote PostgreSQL, scale frontend and backend replicas horizontally, and configure connection pools. See the deployment guide and PostgreSQL setup guide.
    • Console language switching for English, Chinese, Japanese, and Russian.

    Provider Ecosystem

    Provider support is TokenHub's integration boundary. Hosted APIs, subscription channels, local models, and custom upstreams connect through the Provider abstraction so the same enterprise policies can govern every model path.

    Once routing, permissions, token savings, attribution, audit, and reconciliation controls are in place, TokenHub can connect those governed workflows to OpenAI, Azure OpenAI, Anthropic, Gemini, DeepSeek, Qwen, Codex subscriptions, local models, and custom OpenAI-compatible upstreams.

    TokenHub includes native Provider adapters for OpenAI, Azure OpenAI, Anthropic, Gemini, DeepSeek, Qwen, Codex subscriptions, and local models, plus a catalog of 150+ provider templates. Popular integrations include:

    Provider templates use the matching native adapter when available; otherwise they connect through an OpenAI-compatible endpoint. Models and capabilities vary by upstream service and account, while enterprise policy stays centralized in TokenHub.

    Quick Start

    Native Release on a Linux systemd host:

    curl -fsSL https://raw.githubusercontent.com/astaxie/TokenHub/main/deploy/native/install.sh \
      -o /tmp/tokenhub-install.sh
    sudo bash /tmp/tokenhub-install.sh install
    

    Docker Compose from a repository checkout:

    cp deploy/.env.example deploy/.env
    # Replace every change-me value in deploy/.env with a strong secret.
    ./deploy/install.sh
    

    Open:

    • Admin console: http://localhost:3000
    • Backend API: http://localhost:8080
    • Health check: http://localhost:8080/healthz

    Initial admin login:

    • Username: admin
    • Native install password: printed once by the installer
    • Docker password: the value of TOKENHUB_BOOTSTRAP_ADMIN_PASSWORD

    The native installer verifies Release checksums, installs a systemd service, and enables direct update, rollback, and restart controls in the version panel. The default Docker deployment runs the backend and console in one managed container and provides the same direct controls without mounting the Docker socket. Release bundles are stored in the tokenhub-releases volume so ordinary container restarts and recreations preserve a panel-applied update. Multi-instance Docker deployments keep operator-managed Compose updates so every replica changes version together. See the deployment guide for both modes.

    Documentation

    Contributors

    TokenHub grows through product feedback, gateway integrations, documentation, tests, and the steady care of people who run it in real enterprise environments.

    Star History

    License

    TokenHub is licensed under the Apache License 2.0.