Skip to content

Streaming Fails Due to {"include_usage": True} #442

Closed

Description

@sixwaaaay

Description
When using Mistral AI's OpenAI-compatible API with streaming output Runner.run_streamed, the hardcoded stream_options={"include_usage": True} in the code triggers a 422 Unprocessable Entity error. Mistral's API does not support the include_usage parameter in stream_options, causing compatibility issues.

Root Cause:

stream_options={"include_usage": True} if stream else NOT_GIVEN,

Proposed Fix
Add an override mechanism for stream_options

Error

openai.UnprocessableEntityError: Error code: 422 - {'object': 'error', 'message': {'detail': [{'type': 'extra_forbidden', 'loc': ['body', 'stream_options', 'include_usage'], 'msg': 'Extra inputs are not permitted', 'input': True}]}, 'type': 'invalid_request_error', 'param': None, 'code': None}

Activity

  1. rm-openai commented on Apr 7, 2025

    @rm-openai
    Collaborator

    Proposed fix makes sense, PR welcome!

  2. Ddper commented on Apr 10, 2025

    @Ddper
    Contributor

    Proposed fix makes sense, PR welcome!

    @rm-openai I created a PR, pls review.

  3. seratch commented on Jun 25, 2025

    @seratch
    Member

    Resolved by #465; thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions