dzdh
V2EX  ›  OpenAI

不返回 usage 信息怎么办

  •  
  •   dzdh · Dec 6, 2024 · 1715 views
    This topic created in 709 days ago, the information mentioned may be changed or developed.

    记录 token 消耗情况。

    stream 模式同时开启stream_options:{"include_usage':true}使用 4o-mini ,调用image_url分析图片时,发现不返回 usage 信息。怎么破

    3 replies  •  2024-12-07 15:31:07 +08:00
    zhhmax
    zhhmax
    Dec 6, 2024
    1
    你用的 API 来源是正规的吗?我试了一下没问题的:
    data: {"id":"","object":"chat.completion.chunk","created":1733456998,"model":"gpt-4o-mini-2024-07-18","system_fingerprint":"","choices":[],"usage":{"prompt_tokens":8525,"completion_tokens":80,"total_tokens":8605,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}
    dzdh
    dzdh
    OP
    Dec 7, 2024
    2
    @zhhmax 貌似是 azure api-version 参数的问题。2024-08 以后的才支持 include_usage
    zhhmax
    zhhmax
    Dec 7, 2024
    3
    @dzdh 那怪不得,我用的官方 API
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1739 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:01 · PVG 09:01 · LAX 17:01 · JFK 20:01
    ♥ Do have faith in what you're doing.