MCPcopy Index your code
hub / github.com/looplj/axonhub

github.com/looplj/axonhub @v0.9.43 sqlite

repository ↗ · DeepWiki ↗ · release v0.9.43 ↗
26,653 symbols 92,139 edges 1,636 files 15,251 documented · 57%
README

AxonHub - All-in-one AI 开发平台

任意 SDK、任意模型、零代码改动

looplj%2Faxonhub | Trendshift

测试状态 Lint 状态 Go 版本 Docker Ready

English | 中文 | 日本語


注意

  1. 本项目为个人维护,作者不对使用风险作任何保证,请审慎评估。
  2. 本项目核心范围不包括 2api(订阅转 API);如有此类需求,建议使用其他专注于 2api 的开源项目。

📖 项目介绍

All-in-one AI 开发平台

AxonHub 是 AI 网关,让你无需改动一行代码即可切换模型供应商。

无论你使用的是 OpenAI SDK、Anthropic SDK 还是任何 AI SDK,AxonHub 都会透明地将你的请求转换为与任何支持的模型供应商兼容的格式。无需重构,无需更换 SDK——只需更改配置即可。

它解决了什么问题: - 🔒 供应商锁定 - 从 GPT-4 瞬间切换到 Claude 或 Gemini - 🔧 集成复杂性 - 一个 API 格式对接 10+ 供应商 - 📊 可观测性缺口 - 开箱即用的完整请求追踪 - 💸 成本控制 - 实时用量追踪和预算管理

AxonHub Architecture

核心特性 Core Features

特性 你能获得什么
🔄 任意 SDK → 任意模型 用 OpenAI SDK 调用 Claude,或用 Anthropic SDK 调用 GPT。零代码改动。
🔍 完整请求追踪 线程级可观测性的完整请求时间线。更快定位问题。
🔐 企业级 RBAC 细粒度访问控制、用量配额和数据隔离。
智能负载均衡 <100ms 自动故障转移。始终路由到最健康的渠道。
💰 实时成本追踪 每次请求的成本明细。输入、输出、缓存 Token——全部追踪。

📚 文档 | Documentation

文档索引 | Documentation Index

DeepWiki

详细的技术文档、API 参考、架构设计等内容,可以访问 - DeepWiki - zread


🎯 演示 | Demo

在我们的 演示实例 上体验 AxonHub!

注意:演示网站目前配置了 Zhipu 和 OpenRouter 的免费模型。

演示账号 | Demo Account

  • 邮箱 Email: demo@example.com
  • 密码 Password: 12345678

⭐ 特性 | Features

📸 截图 | Screenshots

以下是 AxonHub 的实际运行截图:

系统仪表板 系统仪表板 渠道管理 渠道管理 模型价格 模型价格
模型 模型 追踪查看 追踪查看 请求监控 请求监控

🚀 API 类型 | API Types

API 类型 状态 描述 文档
文本生成(Text Generation) ✅ Done 对话交互接口 OpenAI APIAnthropic APIGemini API
图片生成(Image Generation) ✅ Done 图片生成 Image Generation
重排序(Rerank) ✅ Done 结果排序 Rerank API
嵌入(Embedding) ✅ Done 向量嵌入生成 Embedding API
实时对话(Realtime) 📝 Todo 实时对话功能 -

🤖 支持的提供商 | Supported Providers

提供商 Provider 状态 Status 支持模型 Models 兼容 API
OpenAI ✅ 已完成 GPT-4, GPT-4o, GPT-5 等 OpenAI, Anthropic, Gemini, Embedding, Image Generation
Anthropic ✅ 已完成 Claude 3.5, Claude 3.0 等 OpenAI, Anthropic, Gemini
智谱 AI (Zhipu) ✅ 已完成 GLM-4.5, GLM-4.5-air 等 OpenAI, Anthropic, Gemini
月之暗面 (Moonshot) ✅ 已完成 kimi-k2 等 OpenAI, Anthropic, Gemini
DeepSeek ✅ 已完成 DeepSeek-V3.1 等 OpenAI, Anthropic, Gemini
字节跳动豆包 ✅ 已完成 doubao-1.6 等 OpenAI, Anthropic, Gemini, Image Generation
Gemini ✅ 已完成 Gemini 2.5 等 OpenAI, Anthropic, Gemini, Image Generation
Jina AI ✅ 已完成 Embeddings, Reranker 等 Jina Embedding, Jina Rerank
OpenRouter ✅ 已完成 多种模型 OpenAI, Anthropic, Gemini, Image Generation
ZAI ✅ 已完成 - Image Generation
AWS Bedrock 🔄 测试中 Claude on AWS OpenAI, Anthropic, Gemini
Google Cloud 🔄 测试中 Claude on GCP OpenAI, Anthropic, Gemini
NanoGPT ✅ 已完成 多种模型、图像生成 OpenAI, Anthropic, Gemini, Image Generation

🚀 快速开始 | Quick Start

30 秒本地启动 | 30-Second Local Start

# 下载并解压(以 macOS ARM64 为例)
curl -sSL https://github.com/looplj/axonhub/releases/latest/download/axonhub_darwin_arm64.tar.gz | tar xz
cd axonhub_*

# 使用 SQLite 运行(默认)
./axonhub

# 打开 http://localhost:8090
# 首次运行:按照初始化向导设置系统(创建管理员账号,密码至少需要 6 位)

就这样!现在配置你的第一个 AI 渠道,开始通过 AxonHub 调用模型。

零代码迁移示例 | Zero-Code Migration Example

你的现有代码无需任何改动。 只需将 SDK 指向 AxonHub:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8090/v1",  # 指向 AxonHub
    api_key="your-axonhub-api-key"        # 使用 AxonHub API 密钥
)

# 用 OpenAI SDK 调用 Claude!
response = client.chat.completions.create(
    model="claude-3-5-sonnet",  # 或 gpt-4、gemini-pro、deepseek-chat...
    messages=[{"role": "user", "content": "Hello!"}]
)

切换模型只需改一行:model="gpt-4"model="claude-3-5-sonnet"。无需改动 SDK。


🚀 部署指南 | Deployment Guide

💻 个人电脑部署 | Personal Computer Deployment

适合个人开发者和小团队使用,无需复杂配置。

快速下载运行 | Quick Download & Run

  1. 下载最新版本GitHub Releases
  2. 选择适合您操作系统的版本:

  3. 解压并运行 ```bash # 解压下载的文件 unzip axonhub_.zip cd axonhub_

# 添加执行权限 (仅限 Linux/macOS) chmod +x axonhub

# 直接运行 - 默认使用 SQLite 数据库 # 安装 AxonHub 到系统 ./install.sh

# 启动 AxonHub 服务 ./start.sh

# 停止 AxonHub 服务 ./stop.sh ```

  1. 访问应用 http://localhost:8090

🖥️ 服务器部署 | Server Deployment

适用于生产环境、高可用性和企业级部署。

数据库支持 | Database Support

AxonHub 支持多种数据库,满足不同规模的部署需求:

数据库 支持版本 推荐场景 自动迁移 链接
SQLite 3.0+ 开发环境、小型部署 ✅ 支持 SQLite
TiDB Cloud Starter Serverless, Free tier, Auto Scale ✅ 支持 TiDB Cloud
TiDB Cloud Dedicated 分布式部署、大规模 ✅ 支持 TiDB Cloud
TiDB V8.0+ 分布式部署、大规模 ✅ 支持 TiDB
Neon DB - Serverless, Free tier, Auto Scale ✅ 支持 Neon DB
PostgreSQL 15+ 生产环境、中大型部署 ✅ 支持 PostgreSQL
MySQL 8.0+ 生产环境、中大型部署 ✅ 支持 MySQL

配置文件 | Configuration

AxonHub 使用 YAML 配置文件,支持环境变量覆盖:

# config.yml
server:
  port: 8090
  name: "AxonHub"
  debug: false

db:
  dialect: "tidb"
  dsn: "<USER>.root:<PASSWORD>@tcp(gateway01.us-west-2.prod.aws.tidbcloud.com:4000)/axonhub?tls=true&parseTime=true&multiStatements=true&charset=utf8mb4"

log:
  level: "info"
  encoding: "json"

环境变量:

AXONHUB_SERVER_PORT=8090
AXONHUB_DB_DIALECT="tidb"
AXONHUB_DB_DSN="<USER>.root:<PASSWORD>@tcp(gateway01.us-west-2.prod.aws.tidbcloud.com:4000)/axonhub?tls=true&parseTime=true&multiStatements=true&charset=utf8mb4"
AXONHUB_LOG_LEVEL=info

详细配置说明请参考 配置文档

Docker Compose 部署

# 克隆项目
git clone https://github.com/looplj/axonhub.git
cd axonhub

# 设置环境变量
export AXONHUB_DB_DIALECT="tidb"
export AXONHUB_DB_DSN="<USER>.root:<PASSWORD>@tcp(gateway01.us-west-2.prod.aws.tidbcloud.com:4000)/axonhub?tls=true&parseTime=true&multiStatements=true&charset=utf8mb4"

# 启动服务
docker-compose up -d

# 查看状态
docker-compose ps

Helm Kubernetes 部署 | Helm Kubernetes Deployment

使用官方 Helm Chart 在 Kubernetes 上部署 AxonHub:

# Quick installation
git clone https://github.com/looplj/axonhub.git
cd axonhub
helm install axonhub ./deploy/helm

# Production deployment
helm install axonhub ./deploy/helm -f ./deploy/helm/values-production.yaml

# Access AxonHub
kubectl port-forward svc/axonhub 8090:8090
# Visit http://localhost:8090

关键配置选项:

参数 描述 默认
axonhub.replicaCount 副本数 1
axonhub.dbPassword 数据库密码 axonhub_password
postgresql.enabled 是否启用内嵌 PostgreSQL true
ingress.enabled 是否启用 Ingress false
persistence.enabled 是否启用持久化存储 false

有关详细配置和故障排查,请参阅 Helm Chart 文档

虚拟机部署 | Virtual Machine Deployment

下载最新版本从 GitHub Releases

# 克隆项目
git clone https://github.com/looplj/axonhub.git
cd axonhub

# 设置环境变量
export AXONHUB_DB_DIALECT="tidb"
export AXONHUB_DB_DSN="<USER>.root:<PASSWORD>@tcp(gateway01.us-west-2.prod.aws.tidbcloud.com:4000)/axonhub?tls=true&parseTime=true&multiStatements=true&charset=utf8mb4"

# 安装
sudo ./install.sh

# 配置文件检查
axonhub config check

# 使用管理脚本管理 AxonHub

# 启动
./start.sh

# 停止
./stop.sh

📖 使用指南 | Usage Guide

1. 初始化设置 | Initial Setup

  1. 访问管理界面 http://localhost:8090

  2. 配置 AI 提供商

  3. 在管理界面中添加 API 密钥
  4. 测试连接确保配置正确

  5. 创建用户和角色

  6. 设置权限管理
  7. 分配适当的访问权限

2. Channel 配置 | Channel Configuration

在管理界面中配置 AI 提供商渠道。关于渠道配置的详细信息,包括模型映射、参数覆盖和故障排除,请参阅 渠道配置指南

3. 模型管理 | Model Management

AxonHub 提供灵活的模型管理系统,支持通过模型关联将抽象模型映射到特定渠道和模型实现。这使您能够:

  • 统一模型接口 - 使用抽象模型 ID(如 gpt-4claude-3-opus)替代渠道特定的名称
  • 智能渠道选择 - 基于关联规则和负载均衡自动将请求路由到最优渠道
  • 灵活的映射策略 - 支持精确的渠道-模型匹配、正则表达式模式和基于标签的选择
  • **基于优先级的回

Extension points exported contracts — how you extend this code

APIKeyProvider (Interface)
APIKeyProvider provides API keys for authentication. Implementations can support single or multiple API keys with variou [32 …
llm/auth/api_key_provider.go
Stream (Interface)
Stream represents a generic stream interface The caller should check the Err() method to ensure there's no error. [33 …
llm/streams/stream.go
Inbound (Interface)
Inbound represents a transformer accpet the request from client and respond to client with the transformed response. e.g [38 …
llm/transformer/interfaces.go
Executor (Interface)
Executor interface for making HTTP requests. The Executor interface defines the methods for executing HTTP requests and [18 …
llm/pipeline/executor.go
Noder (Interface)
Noder wraps the basic Node method. [22 implementers]
internal/ent/gql_node.go
CandidateSelector (Interface)
CandidateSelector defines the interface for selecting channel model candidates. [55 implementers]
internal/server/orchestrator/candidates.go
TokenGetter (Interface)
(no doc) [32 implementers]
llm/oauth/token_provider.go
UserOwnedFilter (Interface)
UserOwnedFilter interface for filtering queries by user ID. [4 implementers]
internal/scopes/rule_user_owned.go

Core symbols most depended-on inside this repo

Error
called by 1712
internal/ent/enttest/enttest.go
Len
called by 1044
internal/pkg/xcache/live/indexed.go
Save
called by 778
internal/ent/user_create.go
Close
called by 673
llm/streams/stream.go
Create
called by 661
internal/ent/client.go
Set
called by 631
internal/pkg/xcache/redis/redis.go
Where
called by 623
internal/ent/privacy/privacy.go
Run
called by 569
internal/server/server.go

Shape

Method 15,742
Function 8,349
Struct 1,787
Interface 448
FuncType 224
TypeAlias 92
Class 10
Enum 1

Languages

Go92%
TypeScript8%

Modules by API surface

internal/server/gql/generated.go4,027 symbols
internal/ent/mutation.go2,257 symbols
internal/ent/entql.go506 symbols
internal/ent/client.go496 symbols
internal/ent/gql_pagination.go442 symbols
internal/ent/usagelog_create.go255 symbols
internal/ent/usagelog/where.go251 symbols
internal/ent/channel_create.go227 symbols
internal/ent/request/where.go226 symbols
internal/ent/request_create.go218 symbols
internal/ent/requestexecution/where.go181 symbols
internal/ent/requestexecution_create.go177 symbols

Dependencies from manifests, versioned

ariga.io/atlasv0.38.0 · 1×
cel.dev/exprv0.25.1 · 1×
cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
cloud.google.com/go/monitoringv1.24.3 · 1×
cloud.google.com/go/storagev1.58.0 · 1×
dario.cat/mergov1.0.2 · 1×
entgo.io/contribv0.7.1-0.20260306055 · 1×
entgo.io/entv0.14.6 · 1×

Datastores touched

axonhubDatabase · 1 repos
(mysql)Database · 1 repos

For agents

$ claude mcp add axonhub \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact