langchain-ai/langchain

Reasoning tokens not passing through from OpenRouter to `ChatOpenAI`

Opened this issue ยท 2 comments

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

Run this code and inspect the response and see that it has no reasoning tokens even though anthropic returns them.

import os
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage


chat = ChatOpenAI(
    model="anthropic/claude-sonnet-4",
    api_key=os.environ.get("OPENROUTER_API_KEY"),
    openai_api_base="https://openrouter.ai/api/v1"
)

message = HumanMessage(content="Hello! What's the capital of France now and what was it in 1937?")


response = chat.invoke(
    [message],
    extra_body={'reasoning': {'max_tokens': 10}}
    )
print(f"๐Ÿ“ฅ Response: {response.content}")

Error Message and Stack Trace (if applicable)

No response

Description

I'm using Anthropic Sonnet 4 through OpenRouter on Langchain (for agentic work) and noticed that the reasoning tokens aren't getting passed from OpenRouter to Langchain

System Info

Obtaining file:///Users/sinanozdemir/Fun/langchain/libs/core
Installing build dependencies ... Checking if build backend supports build_editable ... Getting requirements to build editable ... Preparing editable metadata (pyproject.toml) ... Requirement already satisfied: langsmith>=0.3.45 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (0.4.28)
Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (9.1.2)
Requirement already satisfied: jsonpatch<2.0,>=1.33 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (1.33)
Requirement already satisfied: PyYAML>=5.3 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (6.0.2)
Requirement already satisfied: typing-extensions>=4.7 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (4.15.0)
Requirement already satisfied: packaging>=23.2 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (25.0)
Requirement already satisfied: pydantic>=2.7.4 in ./.venv/lib/python3.12/site-packages (from langchain-core==0.3.76) (2.11.9)
Requirement already satisfied: jsonpointer>=1.9 in ./.venv/lib/python3.12/site-packages (from jsonpatch<2.0,>=1.33->langchain-core==0.3.76) (3.0.0)
Requirement already satisfied: httpx<1,>=0.23.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core==0.3.76) (0.28.1)
Requirement already satisfied: orjson>=3.9.14 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core==0.3.76) (3.11.3)
Requirement already satisfied: requests-toolbelt>=1.0.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core==0.3.76) (1.0.0)
Requirement already satisfied: requests>=2.0.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core==0.3.76) (2.32.5)
Requirement already satisfied: zstandard>=0.23.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core==0.3.76) (0.25.0)
Requirement already satisfied: anyio in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core==0.3.76) (4.10.0)
Requirement already satisfied: certifi in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core==0.3.76) (2025.8.3)
Requirement already satisfied: httpcore==1.* in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core==0.3.76) (1.0.9)
Requirement already satisfied: idna in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core==0.3.76) (3.10)
Requirement already satisfied: h11>=0.16 in ./.venv/lib/python3.12/site-packages (from httpcore==1.->httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core==0.3.76) (0.16.0)
Requirement already satisfied: annotated-types>=0.6.0 in ./.venv/lib/python3.12/site-packages (from pydantic>=2.7.4->langchain-core==0.3.76) (0.7.0)
Requirement already satisfied: pydantic-core==2.33.2 in ./.venv/lib/python3.12/site-packages (from pydantic>=2.7.4->langchain-core==0.3.76) (2.33.2)
...
Found existing installation: langchain-core 0.3.76
Uninstalling langchain-core-0.3.76:
Successfully uninstalled langchain-core-0.3.76
Successfully installed langchain-core-0.3.76
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
Obtaining file:///Users/sinanozdemir/Fun/langchain/libs/langchain
Installing build dependencies ... Checking if build backend supports build_editable ... Getting requirements to build editable ... Preparing editable metadata (pyproject.toml) ... Requirement already satisfied: langchain-core<1.0.0,>=0.3.72 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (0.3.76)
Requirement already satisfied: langchain-text-splitters<1.0.0,>=0.3.9 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (0.3.11)
Requirement already satisfied: langsmith>=0.1.17 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (0.4.28)
Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (2.11.9)
Requirement already satisfied: SQLAlchemy<3,>=1.4 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (2.0.43)
Requirement already satisfied: requests<3,>=2 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (2.32.5)
Requirement already satisfied: PyYAML>=5.3 in ./.venv/lib/python3.12/site-packages (from langchain==0.3.27) (6.0.2)
Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.72->langchain==0.3.27) (9.1.2)
Requirement already satisfied: jsonpatch<2.0,>=1.33 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.72->langchain==0.3.27) (1.33)
Requirement already satisfied: typing-extensions>=4.7 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.72->langchain==0.3.27) (4.15.0)
Requirement already satisfied: packaging>=23.2 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.72->langchain==0.3.27) (25.0)
Requirement already satisfied: jsonpointer>=1.9 in ./.venv/lib/python3.12/site-packages (from jsonpatch<2.0,>=1.33->langchain-core<1.0.0,>=0.3.72->langchain==0.3.27) (3.0.0)
Requirement already satisfied: annotated-types>=0.6.0 in ./.venv/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain==0.3.27) (0.7.0)
Requirement already satisfied: pydantic-core==2.33.2 in ./.venv/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain==0.3.27) (2.33.2)
Requirement already satisfied: typing-inspection>=0.4.0 in ./.venv/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.7.4->langchain==0.3.27) (0.4.1)
Requirement already satisfied: charset_normalizer<4,>=2 in ./.venv/lib/python3.12/site-packages (from requests<3,>=2->langchain==0.3.27) (3.4.3)
Requirement already satisfied: idna<4,>=2.5 in ./.venv/lib/python3.12/site-packages (from requests<3,>=2->langchain==0.3.27) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./.venv/lib/python3.12/site-packages (from requests<3,>=2->langchain==0.3.27) (2.5.0)
Requirement already satisfied: certifi>=2017.4.17 in ./.venv/lib/python3.12/site-packages (from requests<3,>=2->langchain==0.3.27) (2025.8.3)
Requirement already satisfied: httpx<1,>=0.23.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.1.17->langchain==0.3.27) (0.28.1)
...
Found existing installation: langchain 0.3.27
Uninstalling langchain-0.3.27:
Successfully uninstalled langchain-0.3.27
Successfully installed langchain-0.3.27
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
Obtaining file:///Users/sinanozdemir/Fun/langchain/libs/text-splitters
Installing build dependencies ... Checking if build backend supports build_editable ... Getting requirements to build editable ... Preparing editable metadata (pyproject.toml) ... Requirement already satisfied: langchain-core<2.0.0,>=0.3.75 in ./.venv/lib/python3.12/site-packages (from langchain-text-splitters==0.3.11) (0.3.76)
Requirement already satisfied: langsmith>=0.3.45 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (0.4.28)
Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (9.1.2)
Requirement already satisfied: jsonpatch<2.0,>=1.33 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (1.33)
Requirement already satisfied: PyYAML>=5.3 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (6.0.2)
Requirement already satisfied: typing-extensions>=4.7 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (4.15.0)
Requirement already satisfied: packaging>=23.2 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (25.0)
Requirement already satisfied: pydantic>=2.7.4 in ./.venv/lib/python3.12/site-packages (from langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (2.11.9)
Requirement already satisfied: jsonpointer>=1.9 in ./.venv/lib/python3.12/site-packages (from jsonpatch<2.0,>=1.33->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (3.0.0)
Requirement already satisfied: httpx<1,>=0.23.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (0.28.1)
Requirement already satisfied: orjson>=3.9.14 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (3.11.3)
Requirement already satisfied: requests-toolbelt>=1.0.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (1.0.0)
Requirement already satisfied: requests>=2.0.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (2.32.5)
Requirement already satisfied: zstandard>=0.23.0 in ./.venv/lib/python3.12/site-packages (from langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (0.25.0)
Requirement already satisfied: anyio in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (4.10.0)
Requirement already satisfied: certifi in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (2025.8.3)
Requirement already satisfied: httpcore==1.
in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (1.0.9)
Requirement already satisfied: idna in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (3.10)
Requirement already satisfied: h11>=0.16 in ./.venv/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->langsmith>=0.3.45->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (0.16.0)
Requirement already satisfied: annotated-types>=0.6.0 in ./.venv/lib/python3.12/site-packages (from pydantic>=2.7.4->langchain-core<2.0.0,>=0.3.75->langchain-text-splitters==0.3.11) (0.7.0)
...
Found existing installation: langchain-text-splitters 0.3.11
Uninstalling langchain-text-splitters-0.3.11:
Successfully uninstalled langchain-text-splitters-0.3.11
Successfully installed langchain-text-splitters-0.3.11
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
โœ… Successfully imported LangChain packages!
langchain_core version: 0.3.76
langchain version: 0.3.27
Creating HumanMessage with content: Hello, LangChain!
โœ… Created test message: content='Hello, LangChain!' additional_kwargs={} response_metadata={}

๐ŸŽ‰ LangChain development environment is working correctly!
Obtaining file:///Users/sinanozdemir/Fun/langchain/libs/partners/openai
Installing build dependencies ... Checking if build backend supports build_editable ... Getting requirements to build editable ... Preparing editable metadata (pyproject.toml) ... Requirement already satisfied: langchain-core<1.0.0,>=0.3.76 in ./.venv/lib/python3.12/site-packages (from langchain-openai==0.3.33) (0.3.76)
Requirement already satisfied: openai<2.0.0,>=1.104.2 in ./.venv/lib/python3.12/site-packages (from langchain-openai==0.3.33) (1.107.3)
Requirement already satisfied: tiktoken<1,>=0.7 in ./.venv/lib/python3.12/site-packages (from langchain-openai==0.3.33) (0.11.0)
Requirement already satisfied: langsmith>=0.3.45 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (0.4.28)
Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (9.1.2)
Requirement already satisfied: jsonpatch<2.0,>=1.33 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (1.33)
Requirement already satisfied: PyYAML>=5.3 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (6.0.2)
Requirement already satisfied: typing-extensions>=4.7 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (4.15.0)
Requirement already satisfied: packaging>=23.2 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (25.0)
Requirement already satisfied: pydantic>=2.7.4 in ./.venv/lib/python3.12/site-packages (from langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (2.11.9)
Requirement already satisfied: jsonpointer>=1.9 in ./.venv/lib/python3.12/site-packages (from jsonpatch<2.0,>=1.33->langchain-core<1.0.0,>=0.3.76->langchain-openai==0.3.33) (3.0.0)
Requirement already satisfied: anyio<5,>=3.5.0 in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (4.10.0)
Requirement already satisfied: distro<2,>=1.7.0 in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (1.9.0)
Requirement already satisfied: httpx<1,>=0.23.0 in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (0.28.1)
Requirement already satisfied: jiter<1,>=0.4.0 in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (0.11.0)
Requirement already satisfied: sniffio in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (1.3.1)
Requirement already satisfied: tqdm>4 in ./.venv/lib/python3.12/site-packages (from openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (4.67.1)
Requirement already satisfied: idna>=2.8 in ./.venv/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (3.10)
Requirement already satisfied: certifi in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (2025.8.3)
Requirement already satisfied: httpcore==1.* in ./.venv/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai<2.0.0,>=1.104.2->langchain-openai==0.3.33) (1.0.9)
...
Found existing installation: langchain-openai 0.3.33
Uninstalling langchain-openai-0.3.33:
Successfully uninstalled langchain-openai-0.3.33
Successfully installed langchain-openai-0.3.33
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
env: OPENROUTER_API_KEY=sk-XX
Creating HumanMessage with content: Hello! What's the capital of France now and what was it in 1937?

๐Ÿ“ค Sending message: Hello! What's the capital of France now and what was it in 1937?
response: ChatCompletion(id='gen-1758055935-3q6eJHmTr4FGfEz1BTPm', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content="Hello! The capital of France is Paris, both now and in 1937. \n\nParis has been the capital of France for many centuries and there hasn't been any change in this regard between 1937 and the present day. It has remained the political, cultural, and economic center of France throughout this entire period.", refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning="This is a straightforward question about geography and history.\n\nThe capital of France now (currently) is Paris.\n\nIn 1937, the capital of France was also Paris. Paris has been the capital of France for many centuries, well before 1937. There wasn't a change in the capital between 1937 and now.\n\nLet me double-check this - Paris became the capital of France in the medieval period and has remained so continuously, except for brief periods during wars (like during WWII when the government fled, but Paris remained the official capital). In 1937, France was still the Third Republic and Paris was definitely the capital.", reasoning_details=[{'type': 'reasoning.text', 'text': "This is a straightforward question about geography and history.\n\nThe capital of France now (currently) is Paris.\n\nIn 1937, the capital of France was also Paris. Paris has been the capital of France for many centuries, well before 1937. There wasn't a change in the capital between 1937 and now.\n\nLet me double-check this - Paris became the capital of France in the medieval period and has remained so continuously, except for brief periods during wars (like during WWII when the government fled, but Paris remained the official capital). In 1937, France was still the Third Republic and Paris was definitely the capital.", 'signature': 'EpYGCkYIBxgCKkCqYI6mN7yNfTw4n3Fw3ZnizbHZ1c4apsdZd6J079KSwcNeWuL3MSm4KXY+bvXOjQywep3C6jpiSEJj1mMD+GzzEgzo/2JY4oJGPVMUoS4aDP3jAsgxMhn6bvC/WyIwf8OfNsft8pFIGX50DHsjgiSWTqugjRGVZmBeH/7+Hnn6HSGiiGzcln2f4XAL6TCeKv0EdLMkxJV9JAUyvJzE99jb6XITl46Sk/xpqK1vbvzOOH8XMkWfjL0A/kcVmW/wxjFGnr1MLGq9k/rLLQi67Tk47UpRnigvpSxJAD5rvfm1XIs36k4H8Z52YfU5R8N5OLpNetVOdQ6OBm6pn08tuB20fCpgDY3JOctGilzKZ5Bzn0wkDsnMY45sZ85Ib+7qIFitX3LcwJyQSTba5tskU9eoopsdXrWTEP8h38O8LY2yziUR7EOCWR44dLoHoKpeY/V0UsQs38JYVL7jONrEo1dCGK/2S2dL6rTq1i8z2SqQdeA07G+arPndTEfM7ee2G+4h7RTRdJTVffsGvdGw6N0fgqeclZdrVdzt7UvET9xPPIDnuC8e8Uta85fAJEf0dHH9Ucv3NTXIvuf3I2GqSMJHEyHT8M+GD/UkmH9p8adkCd4EHmIN4EZ3zEpSQMQ4MSp64w2YZgN5k/Npwd8y/Mtu3GHsPYjQLwsNl37GCJS6yCFSYB1X1TnSLrjQOho7ndDPRpDWZH/RfrwIZ0EGkx5YvwZlpd4xruEgT9B5pDbJ2QBAWpk8UQLUEvmPAKB5USiLy5nkJDzvuiSraksw2MNHqZhP0fuLF/kk9k00RzcNo4h7KX+lh5m9DVv5RSl0Fr3YH8yPQ7GCPfb/kJ/2q0VBvd+N9pZb5fOxjDzbk2skKOnm1HeIJ2F5lM/ztOhdAVNCFOXfHvHauPEnU0G3Emg18Sh+OH1SqjTva5jfHcNmDzgy+jBAGvS+wccX7lmWlTfyeO7zY02B5ZxChatBX8pplFsUy72J1QHKf1sNrqNmFNtFnTLe36qt5FQ7tsnZLQi8Tv0Vib/+VClzIMaHwRgB', 'format': 'anthropic-claude-v1', 'index': 0}]), native_finish_reason='stop')], created=1758055935, model='anthropic/claude-sonnet-4', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=216, prompt_tokens=53, total_tokens=269, completion_tokens_details=None, prompt_tokens_details=None), provider='Anthropic')
๐Ÿ“ฅ Response: Hello! The capital of France is Paris, both now and in 1937.

Paris has been the capital of France for many centuries and there hasn't been any change in this regard between 1937 and the present day. It has remained the political, cultural, and economic center of France throughout this entire period.
๐Ÿ“Š Token Usage:
Input tokens: 53
Output tokens: 216
Total tokens: 269
AIMessage(content="Hello! The capital of France is Paris, both now and in 1937. \n\nParis has been the capital of France for many centuries and there hasn't been any change in this regard between 1937 and the present day. It has remained the political, cultural, and economic center of France throughout this entire period.", additional_kwargs={'refusal': None, 'reasoning_content': "This is a straightforward question about geography and history.\n\nThe capital of France now (currently) is Paris.\n\nIn 1937, the capital of France was also Paris. Paris has been the capital of France for many centuries, well before 1937. There wasn't a change in the capital between 1937 and now.\n\nLet me double-check this - Paris became the capital of France in the medieval period and has remained so continuously, except for brief periods during wars (like during WWII when the government fled, but Paris remained the official capital). In 1937, France was still the Third Republic and Paris was definitely the capital."}, response_metadata={'token_usage': {'completion_tokens': 216, 'prompt_tokens': 53, 'total_tokens': 269, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'anthropic/claude-sonnet-4', 'system_fingerprint': None, 'id': 'gen-1758055935-3q6eJHmTr4FGfEz1BTPm', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--f3718611-64ec-4335-9bf1-5640149e3990-0', usage_metadata={'input_tokens': 53, 'output_tokens': 216, 'total_tokens': 269, 'input_token_details': {}, 'output_token_details': {}})

KeyboardInterrupt Traceback (most recent call last)
Cell In[15], line 1
----> 1 raw_client_response = raw_client.chat.completions.create(
2 model="anthropic/claude-sonnet-4",
3 messages=[{"role": "user", "content": "Hello! What's the capital of France now and what was it in 1937?"}],
4 extra_body={'reasoning': {'max_tokens': 10}}
5 )

File ~/Fun/langchain/.venv/lib/python3.12/site-packages/openai/_utils/_utils.py:286, in required_args..inner..wrapper(*args, **kwargs)
284 msg = f"Missing required argument: {quote(missing[0])}"
285 raise TypeError(msg)
--> 286 return func(*args, **kwargs)

File ~/Fun/langchain/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py:1147, in Completions.create(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, prompt_cache_key, reasoning_effort, response_format, safety_identifier, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, verbosity, web_search_options, extra_headers, extra_query, extra_body, timeout)
1101 @required_args(["messages", "model"], ["messages", "model", "stream"])
1102 def create(
1103 self,
(...) 1144 timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1145 ) -> ChatCompletion | Stream[ChatCompletionChunk]:
1146 validate_response_format(response_format)
-> 1147 return self._post(
1148 "/chat/completions",
1149 body=maybe_transform(
1150 {
...
-> 1106 return self._sslobj.read(len)
1107 except SSLError as x:
1108 if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:

KeyboardInterrupt:
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
ChatCompletion(id='gen-1758055894-j9XPj5rWl0LUiKgOZLNm', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='Hello! The capital of France is Paris, both now and in 1937. \n\nParis has been the capital of France for many centuries, consistently serving in this role with only brief interruptions during certain historical periods. In 1937, France was the Third Republic, and Paris remained its capital city, just as it is today under the Fifth Republic.', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning='This is a straightforward question about the capital of France. \n\nThe capital of France now is Paris, and it has been Paris for a very long time. In 1937, the capital of France was also Paris. Paris has been the capital of France since it was established as such, with some brief exceptions during certain historical periods (like during WWII when there was the Vichy regime, but even then Paris remained the nominal capital, just under German occupation).\n\nSo both answers should be Paris.', reasoning_details=[{'type': 'reasoning.text', 'text': 'This is a straightforward question about the capital of France. \n\nThe capital of France now is Paris, and it has been Paris for a very long time. In 1937, the capital of France was also Paris. Paris has been the capital of France since it was established as such, with some brief exceptions during certain historical periods (like during WWII when there was the Vichy regime, but even then Paris remained the nominal capital, just under German occupation).\n\nSo both answers should be Paris.', 'signature': 'EpQFCkYIBxgCKkDY0p7LmZAkfU9lVCC6/4J3GDDG9ctMqC7fLmu+WMj3BeMOMd/t0HV/VHJwr2Nuf6nVlo7Pj56mw/hKFg4IPM4ZEgyv0Y7q3X2gENKROrIaDEwZtUD1q4AfSc2IuiIwGVKc1qHElT+grebBXANwqClqHcnXYL0Z9JMSf35twFEA9ui1rEt59CipJJ/r9C3tKvsDMDp7ONC458l7Lvvs85UcOwy24ucD90Bl9mo7Uob1w1ZcswVHJAWhVXWdKHTVkOUCPAQZ8jbdzVEQ5wvltIZqlMS6c68vZS0Qwqqas2B3afu/qGdqUsLyWrxQkC2ru0hqowkWtC9kuTVy9b/7BWbH97fUEQlYXj+a8bQJhXwKyqdWqqiNGJDJFfVT1dm65qiEIG8CVwwSLILu9mZ91qDbnGW+UZyx7gXQHgUAR9sR7MbUTEsEmq+rrcrYXchUu/CkvX8YEe1wLfxltPeQi/DFCDjQxKf6LBMOnCDHTU3RhEo9k1ekXxi2ixNJIAjugF+JOU/P/aHiESj0aJXNZYkgb4UK1BFJi+VKovLIfjPj50meGeT0ptRL8YB+wbXcojQHcJE9tHwhK/nncgFKsGlOOruujSyYc0XNtsmlk54VDidP1t2Cy4ghVtwH6rjh6qLF+FMJbA2FBTqWk5LdpOGCcFX7AmJ/wzENbg6OsCEgHkfkdTQM+h7Pr+deGTXqlvjF/ko8waOjXYWkDZGZhU7RfBN9OA9KGWd4j27l9AGdX/CPgDIQvE/i6xArwTWwsR+rqC/+FdKWcGu1cZ+rG+JyS+GeXByyfrMqk8LhkREbVH/4u/8Gbw3sBFkwDl2fmIWOKTfZwkhoHPWRJ/MDlmdHu59gxK0ZtQ3//gKFGAE=', 'format': 'anthropic-claude-v1', 'index': 0}]), native_finish_reason='stop')], created=1758055894, model='anthropic/claude-sonnet-4', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=191, prompt_tokens=53, total_tokens=244, completion_tokens_details=None, prompt_tokens_details=None), provider='Anthropic')

System Information

OS: Darwin
OS Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000
Python Version: 3.12.3 (main, Apr 18 2025, 10:09:16) [Clang 16.0.0 (clang-1600.0.26.6)]

Package Information

langchain_core: 0.3.76
langchain: 0.3.27
langsmith: 0.4.28
langchain_anthropic: 0.3.20
langchain_deepseek: 0.1.4
langchain_openai: 0.3.33
langchain_text_splitters: 0.3.11

Optional packages not installed

langserve

Other Dependencies

anthropic<1,>=0.67.0: Installed. No version info available.
async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
httpx<1,>=0.23.0: Installed. No version info available.
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-azure-ai;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<1.0.0,>=0.3.70: Installed. No version info available.
langchain-core<1.0.0,>=0.3.72: Installed. No version info available.
langchain-core<1.0.0,>=0.3.76: Installed. No version info available.
langchain-core<2.0.0,>=0.3.75: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-openai<1.0.0,>=0.3.28: Installed. No version info available.
langchain-perplexity;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.9: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langsmith-pyo3>=0.1.0rc2;: Installed. No version info available.
langsmith>=0.1.17: Installed. No version info available.
langsmith>=0.3.45: Installed. No version info available.
openai-agents>=0.0.3;: Installed. No version info available.
openai<2.0.0,>=1.104.2: Installed. No version info available.
opentelemetry-api>=1.30.0;: Installed. No version info available.
opentelemetry-exporter-otlp-proto-http>=1.30.0;: Installed. No version info available.
opentelemetry-sdk>=1.30.0;: Installed. No version info available.
orjson>=3.9.14;: Installed. No version info available.
packaging>=23.2: Installed. No version info available.
pydantic<3,>=1: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic>=2.7.4: Installed. No version info available.
pytest>=7.0.0;: Installed. No version info available.
PyYAML>=5.3: Installed. No version info available.
requests-toolbelt>=1.0.0: Installed. No version info available.
requests<3,>=2: Installed. No version info available.
requests>=2.0.0: Installed. No version info available.
rich>=13.9.4;: Installed. No version info available.
SQLAlchemy<3,>=1.4: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
vcrpy>=7.0.0;: Installed. No version info available.
zstandard>=0.23.0: Installed. No version info available.

Hello,

Your token was exposed in your PR description. Please consider it compromised and rotate it.

Hello,

Your token was exposed in your PR description. Please consider it compromised and rotate it.

The OPENROUTER_API_KEY? Yes I caught that immediately and rotated it :) Thank you so much for the comment, I really appreciate it.