You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Global support list - add "openrouter" so supports_response_schema() returns True
The transformation fix is the critical one - without it, even adding to the global list won't work because the schema gets stripped before sending to OpenRouter.
Hope this helps everyone dealing with this! The extra_body workaround is your best bet until the library gets patched. 🔥
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone! 🚀 I ran into this exact issue and found three working solutions
The Problem: OpenRouter models DO support structured outputs, but LiteLLM's
supports_response_schema()
returnsFalse
for them, causing:response_format
Root Cause: LiteLLM doesn't recognize
openrouter
as supporting structured outputs + the OpenRouter adapter strips/rewrites nested schemas.Here's how I fixed it (pick what works for you):
Solution 1: Library Fix for OpenRouter Transformation
For the LiteLLM maintainers: The real issue is in the OpenRouter adapter that strips the
response_format
. Fix it here:AND add OpenRouter to the global support list:
You need both changes - the global list fix alone won't work because the OpenRouter adapter still strips the schema.
Solution 2: No-Code Workaround (For Users Right Now)
Use
extra_body
to inject the proper OpenRouter format:Works immediately with any OpenRouter model that supports structured outputs!
Solution 3: Manual Library Patch (Advanced Users)
If you want to patch your local installation right now:
For CrewAI Users Specifically:
Use Solution 2 with your existing setup:
💡 LiteLLM Team: This needs both fixes!
response_format
dicts"openrouter"
sosupports_response_schema()
returns TrueThe transformation fix is the critical one - without it, even adding to the global list won't work because the schema gets stripped before sending to OpenRouter.
Hope this helps everyone dealing with this! The
extra_body
workaround is your best bet until the library gets patched. 🔥Beta Was this translation helpful? Give feedback.
All reactions