langchain - 💡(How to fix) Fix ChatAnthropic latest version 1.3.4(langchain-anthropic) streaming fails with No generation chunks were returned [8 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35442Fetched 2026-04-08 00:26:08
View on GitHub
Comments
8
Participants
3
Timeline
18
Reactions
0
Author
Timeline (top)
commented ×8labeled ×3mentioned ×3subscribed ×3

model = ChatAnthropic( model=MODEL, api_key=API_KEY, streaming=True, base_url=BASE_URL, ) is failing Version used anthropic="^0.84.0" langchain-anthropic = "^1.3.4"

Test : stream() fails

print("\n--- Test : model.stream() (streaming) ---") try: for chunk in model.stream("Say hello in one sentence."): print(chunk.content, end="|", flush=True) print("\n✅ stream() OK") except Exception as e: print(f"❌ stream() FAILED: {type(e).name}: {e}") print("\nFull stack trace:") traceback.print_exc()

Error Message

Root cause: The Bedrock proxy sends SSE events with only data: lines (no event: field). The anthropic SDK v0.84.0 expects event: message_start, etc. Without those, sse.event is None and all events are silently skipped → 0 chunks → ValueError: No generation chunks were returned.

Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec pydev_imports.execfile(file, globals, locals) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "<location>/chatanthropicexample.py", line 20, in <module> for chunk in model.stream("Write a short 'Hello World' poem."): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<location>/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 601, in stream raise err ValueError: No generation chunks were returned

Root Cause

Root cause: The Bedrock proxy sends SSE events with only data: lines (no event: field). The anthropic SDK v0.84.0 expects event: message_start, etc. Without those, sse.event is None and all events are silently skipped → 0 chunks → ValueError: No generation chunks were returned.

Fix Action

Fix / Workaround

  • 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 posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

anthropic: 0.84.0 asyncpg: 0.31.0 httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.0.9 numpy: 2.4.2 openai: 2.24.0 opentelemetry-api: 1.39.1 opentelemetry-exporter-otlp-proto-http: 1.39.1 opentelemetry-sdk: 1.39.1 orjson: 3.11.7 packaging: 25.0 pgvector: 0.3.6 psycopg: 3.3.3 psycopg-pool: 3.3.0 pydantic: 2.12.5 pytest: 7.4.4 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 rich: 14.3.3 sqlalchemy: 2.0.47 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 wrapt: 1.17.3 xxhash: 3.6.0 zstandard: 0.25.0

Code Example

from langchain_anthropic import ChatAnthropic



BASE_URL = "<organization bedrock url>"
API_KEY = "<KEY>"
MODEL = "anthropic.claude-4-5-opus-v1:0"

model = ChatAnthropic(
    model=MODEL,
    api_key=API_KEY,
    streaming=True,
    base_url=BASE_URL,
)

for chunk in model.stream("Write a short 'Hello World' poem."):
    print(chunk.content, end="|", flush=True)

---

Root cause: The Bedrock proxy sends SSE events with only data: lines (no event: field). The anthropic SDK v0.84.0 expects event: message_start, etc. Without those, sse.event is None and all events are silently skipped → 0 chunks → ValueError: No generation chunks were returned.

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "<location>/chatanthropicexample.py", line 20, in <module>
    for chunk in model.stream("Write a short 'Hello World' poem."):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<location>/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 601, in stream
    raise err
ValueError: No generation chunks were returned
RAW_BUFFERClick to expand / collapse

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 posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

from langchain_anthropic import ChatAnthropic



BASE_URL = "<organization bedrock url>"
API_KEY = "<KEY>"
MODEL = "anthropic.claude-4-5-opus-v1:0"

model = ChatAnthropic(
    model=MODEL,
    api_key=API_KEY,
    streaming=True,
    base_url=BASE_URL,
)

for chunk in model.stream("Write a short 'Hello World' poem."):
    print(chunk.content, end="|", flush=True)

Error Message and Stack Trace (if applicable)

Root cause: The Bedrock proxy sends SSE events with only data: lines (no event: field). The anthropic SDK v0.84.0 expects event: message_start, etc. Without those, sse.event is None and all events are silently skipped → 0 chunks → ValueError: No generation chunks were returned.

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "<location>/chatanthropicexample.py", line 20, in <module>
    for chunk in model.stream("Write a short 'Hello World' poem."):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<location>/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 601, in stream
    raise err
ValueError: No generation chunks were returned

Description

model = ChatAnthropic( model=MODEL, api_key=API_KEY, streaming=True, base_url=BASE_URL, ) is failing Version used anthropic="^0.84.0" langchain-anthropic = "^1.3.4"

Test : stream() fails

print("\n--- Test : model.stream() (streaming) ---") try: for chunk in model.stream("Say hello in one sentence."): print(chunk.content, end="|", flush=True) print("\n✅ stream() OK") except Exception as e: print(f"❌ stream() FAILED: {type(e).name}: {e}") print("\nFull stack trace:") traceback.print_exc()

System Info

python -m langchain_core.sys_info

System Information

OS: Darwin OS Version: Darwin Kernel Version 24.6.0: Wed Nov 5 21:30:44 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6041 Python Version: 3.12.9 (v3.12.9:fdb81425a9a, Feb 4 2025, 12:21:36) [Clang 13.0.0 (clang-1300.0.29.30)]

Package Information

langchain_core: 1.2.15 langchain: 1.2.10 langsmith: 0.7.6 langchain_anthropic: 1.3.4 langchain_openai: 1.1.10 langchain_postgres: 0.0.16 langgraph_sdk: 0.3.9

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

anthropic: 0.84.0 asyncpg: 0.31.0 httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.0.9 numpy: 2.4.2 openai: 2.24.0 opentelemetry-api: 1.39.1 opentelemetry-exporter-otlp-proto-http: 1.39.1 opentelemetry-sdk: 1.39.1 orjson: 3.11.7 packaging: 25.0 pgvector: 0.3.6 psycopg: 3.3.3 psycopg-pool: 3.3.0 pydantic: 2.12.5 pytest: 7.4.4 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 rich: 14.3.3 sqlalchemy: 2.0.47 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 wrapt: 1.17.3 xxhash: 3.6.0 zstandard: 0.25.0

extent analysis

Problem Summary The langchain_anthropic package's stream method fails with a ValueError when trying to stream responses from the Anthropic API.

Root Cause Analysis The issue is caused by a mismatch between the expected and actual format of the SSE events sent by the Bedrock proxy. The anthropic SDK version 0.84.0 expects the events to have an event field, but the Bedrock proxy only sends events with a data field.

Fix Plan

  1. Update langchain_anthropic package: Update the langchain_anthropic package to a version that supports the new format of SSE events sent by the Bedrock proxy.
  2. Patch langchain_core package: Patch the langchain_core package to handle the new format of SSE events.
  3. Temporary workaround: As a temporary workaround, you can disable streaming and fetch the response in chunks using the model.get method.

Code Changes

# Update langchain_anthropic package
pip install --upgrade langchain_anthropic

# Patch langchain_core package
# (This requires modifying the langchain_core package code)
# For now, you can use the temporary workaround below

# Temporary workaround
print("\n--- Test : model.get() (non-streaming) ---")
try:
    response = model.get("Say hello in one sentence.")
    print(response.content)
except Exception as e:
    print(f"❌ get() FAILED: {type(e).__name__}: {e}")
    print("\nFull stack trace:")
    traceback.print_exc()

Verification To verify that the fix worked, run the test code above and check that it prints the response content without any errors.

Extra Tips

  • Make sure to update the langchain_anthropic package to the latest version that supports the new format of SSE events.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - 💡(How to fix) Fix ChatAnthropic latest version 1.3.4(langchain-anthropic) streaming fails with No generation chunks were returned [8 comments, 3 participants]