Hey. OpenAI recently released
stream_options
param which allows users to set
include_usage
flag. Setting this to true will return the
usage
object as the last stream chunk.
Vercel AI currently hardcodes
stream_options: { include_usage: true }
for openai calls and so it also expects the usage object in the stream response. But portkey currently does not hardcode stream_options. Due to this, the stream response does not contain usage object and the validation fails. Can you please add
stream_options
param as mentioned above in your portkey request body and try with that?
stream_options ref:
https://platform.openai.com/docs/api-reference/chat/create#chat-create-stream_optionsvercel ai hardcoded stream_options code ref:
https://github.com/vercel/ai/blob/03eb9e3d34db4734ab8cf927749efaebcec1b217/packages/openai/src/openai-chat-language-model.ts#L200-L203