Thinking content not captured from Openrouter streaming

Open Beginner friendly
#61 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai, api

Research direction

Start in openai_chat.py at norm_sse_event around line 62, then run the stream reproduction from the README and inspect r.raw['deltas'][0]. Done means OpenRouter reasoning under 'reasoning' is captured so Completion.message.content contains PartType.thinking, while the existing direct DeepSeek 'reasoning_content' behavior remains intact.

Written by the indexing model from the issue text.

Description

norm_sse_event in openai_chat.py (line 62) extracts thinking via dlt.get('reasoning_content'), but Openrouter returns reasoning content under the field name reasoning:

{"delta": {"reasoning": "We", "reasoning_details": [...]}}

As a result, when calling DeepSeek (and other models) through OpenRouter, reasoning_tokens are counted but Completion.message.content never contains PartType.thinking — thinking is always None.

Reproduction, using the stream function defined in the readme.

r = await stream([user('What is 2+2?')], model='deepseek/deepseek-v4-flash', vendor_name='openrouter', reasoning_effort='high')

No brains will be output. r.usage shows reasoning tokens have been used, and r.raw['deltas'][0] will show the reasoning content being stored under the key 'reasoning'.

Delta(text='', thinking=None, refusal=None, tool_calls=[], citations=[], server_tool_result=None, finish_reason=None, usage=None, raw={'id': 'gen-1783478615-YqwCVIhusHs2HE5dOmrs', 'object': 'chat.completion.chunk', 'created': 1783478615, 'model': 'deepseek/deepseek-v4-flash-20260423', 'provider': 'AtlasCloud', 'choices': [{'index': 0, 'delta': {'content': '', 'role': 'assistant', 'reasoning': 'We', 'reasoning_details': [{'type': 'reasoning.text', 'text': 'We', 'format': 'unknown', 'index': 0}]}, 'finish_reason': None, 'native_finish_reason': None}]})

I've also tested this with Hunyuan 3 on Openrouter, and it also returns.

Delta(text='', thinking=None, refusal=None, tool_calls=[], citations=[], server_tool_result=None, finish_reason=None, usage=None, raw={'id': 'gen-1783478615-YqwCVIhusHs2HE5dOmrs', 'object': 'chat.completion.chunk', 'created': 1783478615, 'model': 'deepseek/deepseek-v4-flash-20260423', 'provider': 'AtlasCloud', 'choices': [{'index': 0, 'delta': {'content': '', 'role': 'assistant', 'reasoning': 'We', 'reasoning_details': [{'type': 'reasoning.text', 'text': 'We', 'format': 'unknown', 'index': 0}]}, 'finish_reason': None, 'native_finish_reason': None}]})

And with Gemma 4 31B.

Delta(text='', thinking=None, refusal=None, tool_calls=[], citations=[], server_tool_result=None, finish_reason=None, usage=None, raw={'id': 'gen-1783479613-fRKBw5Vto4vcuUwNVjUZ', 'object': 'chat.completion.chunk', 'created': 1783479613, 'model': 'google/gemma-4-31b-it-20260402', 'provider': 'WandB', 'choices': [{'index': 0, 'delta': {'content': '', 'role': 'assistant', 'reasoning': 'The', 'reasoning_details': [{'type': 'reasoning.text', 'text': 'The', 'format': 'unknown', 'index': 0}]}, 'finish_reason': None, 'native_finish_reason': None}]})

Due to my region, I'm unable to try Sonnet/Opus/GPT through Openrouter.

This is in contrast to using, say, the Deepseek API directly, which will return 'reasoning_content' when looking at r.raw['deltas'][0].

Delta(text=None, thinking='', refusal=None, tool_calls=[], citations=[], server_tool_result=None, finish_reason=None, usage=None, raw={'id': 'c7211552-934d-47be-9bdb-9addb3a0d7b9', 'object': 'chat.completion.chunk', 'created': 1783478377, 'model': 'deepseek-v4-flash', 'system_fingerprint': 'fp_8b330d02d0_prod0820_fp8_kvcache_20260402', 'choices': [{'index': 0, 'delta': {'role': 'assistant', 'content': None, 'reasoning_content': ''}, 'logprobs': None, 'finish_reason': None}], 'usage': None})

Dominant language
Jupyter Notebook
Stars
15
Forks
5
Avg merge
1h 23m
Merged PRs (30d)
12

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AnswerDotAI/fastllm

All issues in AnswerDotAI/fastllm

Similar issues

More AI Infra & Agents issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.