anthropics / anthropics/anthropic-sdk-python

Token counting is not supported in Bedrock yet

未关闭
#1,103 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
3.9k
派生
853
平均合并
1 天 11 小时
30 天内合并 PR
10

描述

```python
client = AnthropicBedrock(
aws_access_key=AWS_BEDROCK_ACCESS_KEY,
aws_secret_key=AWS_BEDROCK_SECRET_KEY,
)
client.messages.count_tokens(model="global.anthropic.claude-sonnet-4-5-20250929-v1:0", messages=[{"role": "user", "content": "test"}])
```

**anthropic.AnthropicError: Token counting is not supported in Bedrock yet**

---

The message I get from trying to count tokens using `AnthropicBedrock` is pretty clear. It's not supported.

But docs (https://platform.claude.com/docs/en/api/overview#third-party-platform-apis) says `Token counting` is supported on all 3rd party platform APIs.

That's a bit confusing.

Am I doing something wrong in the sdk?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。