camel icon indicating copy to clipboard operation
camel copied to clipboard

[Feature Request] During streaming, return usage

Open hzzhyj opened this issue 1 month ago • 2 comments

Required prerequisites

  • [x] I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
  • [x] Consider asking first in a Discussion.

Motivation

If we stream a response, the usage is not returned.

Even after enabling usage via

model_config_dict={
    "stream": True,
    "stream_options": {"include_usage": True},
},

the input tokens and output token counts are not returned. Testing using gemini api directly do support input and output token counts

Only a total tokens is returned which is not enough for billing purposes as input token price and output token price are not the same

Solution

Support returning input token and output token count for streamed responses

Alternatives

Well there is not alternative really. Just have to support that

Additional context

No response

hzzhyj avatar Nov 12 '25 20:11 hzzhyj

thanks @hzzhyj for reporting this issue,its because the structure gemini returned is different with openai,will adapt it.

fengju0213 avatar Nov 13 '25 06:11 fengju0213

will fixed in https://github.com/camel-ai/camel/pull/3326

fengju0213 avatar Nov 14 '25 04:11 fengju0213