AxonHubClient
AxonHubClient 是用于管理 AxonHub 实例的 Python client 和命令行工具。它面向 AxonHub Admin API,通过 Admin Token 访问 /admin/graphql,用于盘点和管理渠道、模型、API Key / Profile、用量、请求日志、Trace 和诊断信息。
上游项目:AxonHub
AxonHub 是一个开源 AI Gateway / AI 开发平台,目标是在不更换业务代码和 SDK 的前提下,把 OpenAI、Anthropic、Gemini 等不同模型供应商接入到统一网关中。它提供模型供应商切换、统一 API 入口、智能负载均衡、故障转移、用量与成本统计、请求追踪和后台管理等能力。
本项目不替代 AxonHub 本体,而是围绕已有 AxonHub 实例提供可脚本化、可被 Agent 调用的管理层:通过命令行或 Python client 管理渠道、模型、API Key / Profile、用量和诊断信息。
适用场景
- 查看 AxonHub 实例中的渠道、模型、用量和请求状态。
- 按 AxonHub Project 盘点 API Key / Profile、请求、用量日志和 Trace。
- 批量导入、创建、更新、启停或排序渠道。
- 管理模型和模型关联规则。
- 检查渠道健康状态、请求日志、用量日志和 Trace。
- 在自动化脚本或 Agent 工作流中复用同一套 AxonHub 管理操作。
本项目不负责获取上游 API 资源。调用方应确保传入的 endpoint、API key 和模型信息已经获得授权。
文档
安装
推荐使用 uv 作为独立命令行工具安装:
uv tool install axonhub-client
axonhub-client --help
升级和卸载:
uv tool upgrade axonhub-client
uv tool uninstall axonhub-client
Windows 用户也可以从 GitHub Release 下载 axonhub-client-windows-x64-vX.Y.Z.zip,解压后直接运行:
.\axonhub-client.exe --help
从源码目录开发时:
uv sync --extra dev
uv run axonhub-client --help
命名约定:安装包、CLI 命令和发布产物使用 axonhub-client;Python import 包名使用 axonhub_client。
快速开始
首次使用先登录 AxonHub 管理后台。登录成功后,CLI 会把默认 session 保存到当前用户配置目录;session 文件保存实例地址、token、用户摘要和保存时间,不保存密码。
axonhub-client auth login --url https://your-axonhub.example.com --username admin@example.com
上面的命令会继续提示输入密码,密码输入不会回显。需要非交互登录时,可以显式传入 --password:
axonhub-client auth login --url https://your-axonhub.example.com --username admin@example.com --password "your-password"
auth login 也可以不传参数,按提示交互式输入实例地址、用户名和密码。
常用盘点命令:
axonhub-client --json inventory summary
axonhub-client --json channels list
axonhub-client --json models list
axonhub-client --json api-keys list --status enabled
axonhub-client --project <project-id> --json requests list --first 20
axonhub-client --json diagnostics channel-health --limit 10
--project <project-id> 是全局参数,专指 AxonHub Project。它会作为 X-Project-ID 请求上下文,并用于 API Key / Profile、请求、用量日志和 Trace 等项目归属资源的列表过滤。
创建或修改资源时,命令默认只预览将要执行的操作,不会直接修改 AxonHub。确认无误后,再追加 --confirm 执行真实变更:
axonhub-client channels create `
--type openai `
--name "openai-main" `
--upstream-base-url "https://api.openai.com/v1" `
--api-key "sk-..." `
--tag prod
axonhub-client channels create `
--type openai `
--name "openai-main" `
--upstream-base-url "https://api.openai.com/v1" `
--api-key "sk-..." `
--tag prod `
--confirm
更多命令、参数和输入文件格式见 使用说明。
Python Client
也可以在 Python 代码中直接使用 client:
from axonhub_client import AxonHubClient
client = AxonHubClient.from_config(
"https://your-axonhub.example.com",
admin_token="your-admin-token",
)
channels = client.channels.list(first=20)
安全说明
- 创建、修改、删除等操作默认只预览,不会直接修改 AxonHub;传入
--confirm后才会执行。 - 命令输出会自动遮盖常见敏感信息,例如 API key、token 和密码。
- 查询渠道时不会读取渠道中保存的上游密钥配置。
- 查询已禁用的渠道密钥时不会读取密钥明文。
- 查看 AxonHub API Key / Profile 信息时不会读取 API key 明文。
auth login不保存密码,默认也不会打印登录 token。- 测试渠道和测试渠道内 API key 会真实请求上游服务,可能消耗额度,因此也需要显式确认。
许可证
本项目使用 Apache License 2.0,详见 LICENSE。
Metadata
Release files for axonhub-client 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| axonhub_client-0.1.1.tar.gz | 56.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| axonhub_client-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.2 kB
Release files / axonhub_client-0.1.1.tar.gz
| Download URL | axonhub_client-0.1.1.tar.gz |
|---|---|
| Size | 56.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7df513c01043305e900ff3d22f733b09d15308eefcf5f27891f3ecce564b03cf
|
|
BLAKE2b-256 checksum How to use checksums |
f7fc6e9565186051dec3898ee2864998abd2890d52d5a9dc31cfbc2cfb96869d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logRelease files / axonhub_client-0.1.1-py3-none-any.whl
| Download URL | axonhub_client-0.1.1-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1936ed482a5b26f62abb384e2a47ea110b43b3a7d39f1bbfc5ea1efb537771df
|
|
BLAKE2b-256 checksum How to use checksums |
f0a2b8df50639c99947c00949724e15c3def196ae08001872412b2069e7344d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logSecurity for axonhub-client 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for axonhub_client-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.