[BUG] API 400 This model's maximum context length is XXX tokens. Opus 4.7

Resolved 💬 2 comments Opened Apr 17, 2026 by seanconnolly2000 Closed Apr 18, 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?

I've not experienced this issue in my 6 months of working with Claude Code and various models (generally I've been using Opus 4.6, today it was upgraded automatically to 4.7). Generally, all context is handled quite nicely by Claude Code, but this evening, twice now, I've received this error, Opus is unable to finish it's task:

Searched for 1 pattern, read 1 file, listed 3 directories (ctrl+o to expand)
⎿  API Error: 400 {"error":{"message":"This model's maximum context length is 102400 tokens. However, you requested 103057 tokens (39057 in the messages, 64000 in the completion).
Please reduce the length of the messages or completion.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

I checked and my claude code is the most current version (2.1.112). My request was simply to add a new feature to a python project (which it has done successfully always in the past).

What Should Happen?

Claude should manage it's context window with the model as it alway has, not throwing a 400 error.

Error Messages/Logs

Searched for 1 pattern, read 1 file, listed 3 directories (ctrl+o to expand)
  ⎿  API Error: 400 {"error":{"message":"This model's maximum context length is 102400 tokens. However, you requested 103057 tokens (39057 in the messages, 64000 in the completion).
     Please reduce the length of the messages or completion.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

Steps to Reproduce

  1. Have claude code scan a moderate sized python project with a backend (python/fastapi) and frontend (react) components. Ask it to create a new feature that requires knowledge of the front end, routers, apis, and sql database. It starts "sauteeing" and then generates the error. I tried this twice.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.112 with Opus 4.6

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗