[BUG] undefined is not an object (evaluating '$.speed')" on direct Anthropic API (not Bedrock)

Status Closed — duplicate
Reported on v2.1.87
Maintainer reply None cached
Activity 12 comments · opened Mar 30, 2026 · closed Aug 19, 2026

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"
}

View original on GitHub ↗

11 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/40189
  2. https://github.com/anthropics/claude-code/issues/40260
  3. https://github.com/anthropics/claude-code/issues/40485

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

yuleyi · 5 months ago

I also meet this issue. I resolved it by reverting back to v2.1.81

KaykLynn · 5 months ago
I also meet this issue. I resolved it by reverting back to v2.1.81

Not working to me 😭

zurriburro · 4 months ago

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.

FirstOFficer1 · 4 months ago

Same error, I hope it will fix soon. Used pychram and vscode

DarrenBaldwin07 · 4 months ago

we are seeing this issue too pretty consistently, a couple users get it almost 90% of the time pretty consistently

visilica · 4 months ago

i have same on windows

tzachshabtay · 4 months ago

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.

yuseferi · 4 months ago

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" />

hhj233 · 4 months ago

i hava same on linux. how to solve it ?

yuseferi · 4 months ago

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!

Showing cached comments. Read the full discussion on GitHub ↗