Skip to content

Conversation

kankute-sameer
Copy link
Contributor

Fix text_format parameter handling in litellm.responses() for structured output

Relevant issues

Fixes #13789

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

testing

Screenshot 2025-09-03 at 5 42 28 PM

Type

🐛 Bug Fix
🧹 Refactoring

Changes

The issue was that the response_format parameter was not defined for SDK-related requests, hence even after specifying it in the request, the response was not a structured output. This used to work fine for Litellm proxy because when openai client is used, it sends the "text" param to Litellm, and then Litellm handles it correctly. But when for SDK implementation, OpenAI Python SDK uses "response_format" which is later converted to "text" param(this was not in litellm hence it used to fail) before sending to the api call. I have added that and now both sdk and proxy are able to accept and give structured output.

Copy link

vercel bot commented Sep 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Sep 6, 2025 4:21pm

@vaibhavmano
Copy link

Can this PR be reviewed and merged on priority?

@Jai1625
Copy link

Jai1625 commented Sep 4, 2025

We are trying to use this in responses sdk can this be merged on priority

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move mock test inside test_litellm/ so it runs through the github action

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the code that is causing tests to fail. It was functionality i added in other PR, but was removed later, I suppose its test case remained. I have removed it. After merge of this PR, that should be fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still failing due to some error that is out of scope of this PR

cursor[bot]

This comment was marked as outdated.

@krrishdholakia krrishdholakia merged commit a28f877 into BerriAI:main Sep 6, 2025
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Structured output text_format is ignored in responses API
4 participants