Skip to content

fix(openai-compatible): support openrouter reasoning field #6361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

twxia
Copy link
Contributor

@twxia twxia commented May 16, 2025

Background

OpenRouter's reasoning field is like the below data chunk example:
"delta":{"role":"assistant","content":"...","reasoning":"..."}

People can only use third party provider's library to get the reasoning field, https://ai-sdk.dev/providers/community-providers/openrouter#openrouter, but not @ai-sdk/openai-compatible. I'm not sure if we want to support it in @ai-sdk/openai-compatible.

Summary

To support OpenRouter's reasoning field in the @ai-sdk/openai-compatible

Verification

Run in my own project with OpenRouter provider provided to createOpenAICompatible

Tasks

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • Formatting issues have been fixed (run pnpm prettier-fix in the project root)

Future Work

Should we expose the raw data chunk to middleware to better support those edge cases? Right now, if the vercel/ai doesn't know the field, that field gets silently dropped and no one can retrieve it from a middleware.

Related Issues

#6226

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.

1 participant