V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
lzoje
1.05D

OpenAI API 接口延迟测量工具

  •  
  •   lzoje · Feb 12, 2025 · 2301 views
    This topic created in 448 days ago, the information mentioned may be changed or developed.

    不知道大家有没有同时用多个大模型服务提供商的 api 。

    最近 deepseek 官方接口一直很慢,于是转向使用第三方服务商提供的 deepseek api ,但是这些服务商的 api 速度也是参差不齐,时快时慢。

    所以我用 python 写了一个 openai 格式 api 的延迟测量工具,测量接口返回回答的时间。可以同时测量多个 api 的延迟,本地加密保存 key 。个人感觉还是有点用,不用手动写 curl 了。

    github 仓库: OpenAI API latency

    Supplement 1  ·  Feb 12, 2025
    支持了并行执行,多次测试取均值。
    Supplement 2  ·  Feb 12, 2025

    执行结果

    Supplement 3  ·  Feb 12, 2025

    执行结果

    Supplement 4  ·  Feb 12, 2025

    添加了展示 ttft (time to first token) 数据

    ttft

    2 replies    2025-02-12 17:10:42 +08:00
    Vegetable
        1
    Vegetable  
       Feb 12, 2025   ❤️ 1
    评估 API 至少有两个关键指标:

    - 第一个 token 返回时间
    - token 生成速度

    可以看看 https://openrouter.ai/deepseek/deepseek-chat/providers 这个 dashboard 是怎么评价 provider 的,当然我也没见过几个类似的评估,只是说一下第一印象。

    你的代码我也看了一下,感觉如果交给 ai 整理一下,观感会好一点,你现在缩进太多了。
    lzoje
        2
    lzoje  
    OP
       Feb 12, 2025
    @Vegetable 这个确实不是比较专业的 api 评估工具,本意基本上和 TTFT 差不多。因为目前用了很多不同服务商提供的 api ,所以想简单量化下不同服务商的 api 延迟速度。目前的逻辑就是测量发个请求后到获取应答的时间。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5702 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 06:49 · PVG 14:49 · LAX 23:49 · JFK 02:49
    ♥ Do have faith in what you're doing.