-
-
Notifications
You must be signed in to change notification settings - Fork 134
Description
TanStack AI version
0.5.1
Framework/Library version
React 19
Describe the bug and the steps to reproduce it
There is an issue mixing snake case with camelCase around the openrouter model options. The snake_case options passed through to chat in the openrouter adapter are silently ignored.
There is a test "maps options into the Chat Completions API payload" that tests if tool_choice ends up in the params payload sent to the openrouter sdk - which it does - BUT that doesn't properly test that it gets sent as part of the http request to openrouter.
What happens, is that all fields sent to the openrouter sdk pass through a Zod transformer which transforms camelCase inputs to snake_case outputs and ignores any other field. In the example above, you should pass toolChoice. That gets mapped to tool_choice by the openrouter sdk, but if you pass tool_choice in snake_case it will be stripped out.
This can be solved in one of two ways:
- Redo the convert-openrouter-models script to transform all of the snake_case types in the open api specs to camel case. This would be a breaking change, but is probably the right thing to do, OR
- Transform modelOptions from snake_case to camelCase before passing to the openrouter SDK
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
It's easier to see this in a PR. I'll raise one
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.