anthropics / anthropics/anthropic-sdk-python

API "Streaming is required" error message is outdated

未關閉
#1,430 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
3.9k
分支
853
平均合併
1 天 11 小時
30 天內合併 PR
10

描述

Providing a max_tokens parameter greater than ~20k tokens without using the streaming API produces an error which references "https://github.com/anthropics/anthropic-sdk-python#long-requests", a heading which no longer exists since [0e409217](https://github.com/anthropics/anthropic-sdk-python/commit/0e4092173fc52d773675f8e3a4ced6a5e2f67c9f).

Two points:
1. This error message should be re-pointed to wherever the documentation currently lives
2. What is the right thing to do here, if for whatever reason we cannot use the streaming API? It no longer seems possible to omit the max_tokens field when making an API request, so I assume the prior advice is no longer appropriate. I can call _calculate_nonstreaming_timeout to determine the 'safe non-streaming maximum' but that's obviously brittle.

Full error:
```
File "/proj/api.py", line 615, in _execute_request
text, inp, out, cached = await self._execute_anthropic(request, model_id, self._get_anthropic())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/proj/api.py", line 441, in _execute_anthropic
response = await client.messages.create(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib64/python3.14/site-packages/anthropic/resources/messages/messages.py", line 2425, in create
timeout = self._client._calculate_nonstreaming_timeout(
max_tokens, MODEL_NONSTREAMING_TOKENS.get(model, None)
)
File "/.venv/lib64/python3.14/site-packages/anthropic/_base_client.py", line 732, in _calculate_nonstreaming_timeout
raise ValueError(
...<2 lines>...
)
ValueError: Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#long-requests for more details
```

This is with v0.88, but as far as I can tell there were no changes to the relevant documentation files since then.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。