Skip to main content

AI 中转站测速与可用率自检(api-relay-benchmark)

一个不依赖第三方的小脚本:给你自己常用的中转站端点测可用率、状态码、延迟中位数,输出 Markdown 表格贴进 issue、周报或者监控告警里。

中转站评测/中转站测速/API 中转站可用率 · 不需要装包,只用 Python 标准库。

为什么需要它

中转站的"能不能用"和"快不快"是两件事,而且都会随时间变化。别人写的排行榜是别人那一刻的测量结果;你自己跑一次,才知道此刻哪条线路是通的。

安装

不需要安装。只要 Python 3.8+:

git clone https://github.com/kuku-momo/api-relay-benchmark
cd api-relay-benchmark

用法

# 测两个端点,各跑 3 次
python3 bench.py https://ai.tt2066.top/v1 https://api.openai.com/v1 --key $RELAY_KEY

# 端点写在文件里,跑 5 次,顺便存 JSON
python3 bench.py --file endpoints.txt --rounds 5 --json report.json

输出:

| 端点 | 成功/次数 | 状态码 | 中位延迟 | 最快 | 最慢 |
|---|---|---|---|---|---|
| https://ai.tt2066.top/v1 | 3/3 | 200 | 412.3ms | 388.1ms | 470.9ms |

怎么读结果

  • 4xx 全部失败:Key 不对或模型未开通,不是网络问题;
  • 5xx 抖动:上游通道不稳,看是否连续;
  • 中位延迟高但最快值正常:链路拥塞或限流,不是端点本身慢;
  • 只有 error 列有内容:DNS / TLS / 超时,先查本地网络。

端点填什么

填到 /v1(OpenAI 兼容)。脚本会自动拼 /models。Anthropic 兼容的端点用 /v1/messages,本脚本只测 OpenAI 侧连通性。

相关文档

License

MIT

Metadata

Release files for ttapi-relay-bench 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ttapi-relay-bench 0.1.0
File Size Uploaded Provenance Actions
ttapi_relay_bench-0.1.0.tar.gz 4.4 kB Without provenance Details for ttapi_relay_bench-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ttapi-relay-bench 0.1.0
File Interpreter ABI Platform Actions
ttapi_relay_bench-0.1.0-py3-none-any.whl Python 3 none any Details for ttapi_relay_bench-0.1.0-py3-none-any.whl

Total release size: 9.4 kB

Release files / ttapi_relay_bench-0.1.0.tar.gz

Download URL ttapi_relay_bench-0.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
34d384184031a0de5943347f5a09b80a6d15b9b28f014c165a8f3d42ce97be96
BLAKE2b-256 checksum
How to use checksums
531c54694eebf0fc11a8c52e787e7d064d3c33ac32ac744c00421c886cc09ec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / ttapi_relay_bench-0.1.0-py3-none-any.whl

Download URL ttapi_relay_bench-0.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c4d87b71ffc26fc8da4867b9ca6143dbf106f995a83caa6c42de1c322f43f64
BLAKE2b-256 checksum
How to use checksums
928ee78e35c6c7b950afee1a4389302e2cbeed5d58918a3f0d85f7eda0f154e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for ttapi-relay-bench 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page