anthropics / anthropics/claude-agent-sdk-python
[BUG] Incorrect total_cost_usd being returned by the SDK.
- Vorherrschende Sprache
- Python
- Sterne
- 8.1k
- Forks
- 1.3k
- Ø Merge
- 2 T. 31 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
### Problem:
1. I'm using Sonnet 4.6,
2. The agent is infact using Sonnet 4.6,
3. The usage values are right (token consumption)
4. I am being charged for Sonnet 4.6
5. But the total_cost_usd aligns with that of Opus 4.6.
### How I've verified
I've created a new API key on platform.claude.com, and I've monitored a run for a very simple "hello good morning" message. My system prompt's too large, so that's the reason why the cache_creation_tokens are through the roof.
**Before (New API key):**
**The usage & cost values:**
```
"value": {
"usage": {
"input_tokens": 3,
"cache_creation_input_tokens": 60710,
"cache_read_input_tokens": 2170,
"output_tokens": 122,
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 60710
},
"inference_geo": "",
"iterations": [],
"speed": "standard"
},
"total_cost_usd": 0.38358749999999997
}
```
**After run (Claude Platform):**
**For that usage, here's how the cost looks like for Sonnet 4.6 and Opus 4.6:**
As you can see, the Agent SDK's total_cost_usd aligns with Opus 4.6 despite the agent actually using Sonnet 4.6.
**What I've tried:**
Apart from passing the model as a parameter to the agent, I've also defined it in the settings.json (assuming some CLI setting is messing it all up), but it was all in vain.
How do I get the right cost values from Claude Agent SDK? Is this a bug in the CLI binary / the SDK, or a problem with my configuration?
I'm passing in the model as a parameter to the agent, and the agent is running all fine, but why is the cost value wrong?
Please let me know if you need any more information.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.