[BUG] undefined is not an object (evaluating '$.speed')" on direct Anthropic API (not Bedrock)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
### Bug Description
Getting undefined is not an object (evaluating '$.speed') intermittently when using
Claude Code with the direct Anthropic API (not Bedrock, not Vertex). This appears to be
the same root cause as #40189, but that issue is Bedrock-specific — this confirms the
bug also affects the standard Anthropic API provider.
### Environment
- Claude Code version: 2.1.87
- Provider: Anthropic API (direct, no Bedrock/Vertex)
- OS: Ubuntu Linux (6.14.0-37-generic)
- Model: claude-opus-4-6
Related
- #40189 (same error, but Bedrock-specific)
What Should Happen?
The client should use optional chaining (?.speed) or a null check when accessing
the speed field from API usage metadata, as it can be null.
Error Messages/Logs
Steps to Reproduce
The error occurs intermittently — not on every request. In a single day (2026-03-29),
it appeared 8 times across 5 separate sessions. All occurrences are logged as
isApiErrorMessage: true with model: "<synthetic>", indicating a client-side
parsing failure rather than an actual API error.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
### Relevant session log data
```json
{
"message": {
"model": "<synthetic>",
"usage": { "speed": null },
"content": [{ "type": "text", "text": "undefined is not an object (evaluating '$.speed')" }]
},
"isApiErrorMessage": true,
"version": "2.1.87"
}
Showing cached comments. Read the full discussion on GitHub ↗
11 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I also meet this issue. I resolved it by reverting back to v2.1.81
Not working to me 😭
Same issue. Using Claude Code via Antigravity's terminal. Anthropic API
Model: Claude Opus on Plan Mode (high effort)
Antigravity Version: 1.21.6
VSCode OSS Version: 1.107.0 (user setup)
OS: Windows_NT x64 10.0.26200
Happens only randomly.
Same error, I hope it will fix soon. Used pychram and vscode
we are seeing this issue too pretty consistently, a couple users get it almost 90% of the time pretty consistently
i have same on windows
Note I had this too with a brew install, not transient, happened 100% of the time (and understood from friends they had it with the native installer as well). uninstalling and installing with npm solved it for me.
it's happening for me on mac on latest version
⏺ undefined is not an object (evaluating '_.speed'
claude --version
2.1.104 (Claude Code)
<img width="1432" height="184" alt="Image" src="https://github.com/user-attachments/assets/2c6c21b0-8d75-4dcd-9b96-2230ddeca1d8" />
<img width="1220" height="198" alt="Image" src="https://github.com/user-attachments/assets/a90b7365-b7a6-4313-82a7-37c94fb27386" />
i hava same on linux. how to solve it ?
I found a simple solution for this one, close all ( kill ) all calude-code that are running in different terminal etc,
And restart the terminal session, fix the issue for me!