Skip to content

OpenRouter: streamed chunks carry reasoning only as delta.reasoning_content, not delta.reasoning #659

Done

Description

@TehilaTheStudent

What happens

For OpenRouter (/api/v1/chat/completions), a fixture's reasoning is streamed only as choices[].delta.reasoning_content. OpenRouter's streaming API sends it as delta.reasoning. Non-streamed replies already mirror it into message.reasoning (dist/openrouter-chat.js), but streamed chunks don't.

Clients that read only OpenRouter's field miss the reasoning when streaming. For example, langchain-openrouter 0.3.0's ChatOpenRouter reads delta.reasoning.

Seen on 1.48.1 and 1.49.0.

Reproduce

aimock -p 4010 &
curl -s -X POST localhost:4010/__aimock/fixtures -H 'content-type: application/json' -d '{"fixtures": [
  {"match": {"userMessage": "t2:", "model": "or"}, "response": {"content": "ANSWER", "reasoning": "I think."}}]}'

curl -sN -X POST localhost:4010/api/v1/chat/completions -H 'content-type: application/json' \
  -d '{"model": "or", "stream": true, "messages": [{"role": "user", "content": "t2: hi"}]}'
# deltas carry "reasoning_content": "I think." and no "reasoning"

ChatOpenRouter(model="or", base_url="http://localhost:4010/api/v1").stream("t2: hi") yields the answer with no reasoning.

Expected

Streamed OpenRouter chunks carry the reasoning as delta.reasoning, as the non-streamed replies already do in message.reasoning.

Activity

  1. added a commit that references this issue on Dec 3, 2026
    1665af7
  2. jpr5 commented on Dec 4, 2026

    @jpr5
    Contributor

    Good catch, thanks. Fixed in #663: the OpenRouter route now streams delta.reasoning and reasoning_details like the real API does. reasoning_content is still there, so nothing breaks for anyone reading it.

    While we were in there we found recording had the same blind spot and was dropping OpenRouter reasoning from fixtures. That's fixed in #664. Both land in the next release.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions