---
title: 'API Error: Claude''s response exceeded the 32000 output token maximum'
url: https://calvin.my/posts/api-error-claude-s-response-exceeded-the-32000-output-token-maximum
published: 2025-09-30
updated: 2026-09-13
category: AI
tags:
- Claude
- Anthropic
- Claude Code
summary: Claude Code may fail when a response exceeds its default 32,000-token output limit. The post recommends first simplifying prompts that trigger unnecessary large output, such as generated test data. If more capacity is needed, users can raise the configured output limit and switch to a compatible model such as Sonnet. It also notes that Claude Opus 4.6 supports up to 128,000 output tokens.
---

# API Error: Claude's response exceeded the 32000 output token maximum

Sometimes, the Claude Code tool shows an error message like the following:

```bash
API Error: Claude's response exceeded the 32000 output token maximum. 
To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
```

This is the default max token for the tool, as well as in the Opus model.

* * *

## Solution 1:&nbsp;Review your prompt and retry

Example: In a rare situation, the model tries to output an unnecessary string. For example, when generating a dummy PNG file for testing, it uses echo with a long string. You can provide the path to a test image, instruct it to use dummy image URLs, or skip the test.

* * *

## Solution 2: Adjust the environment variable as suggested

Update the max output tokens to 64000 and resume the Claude session. Note that you need to tune your model to a supported one, for example, Sonnet.

```bash
$ export CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000

$ claude -r
```

* * *

## Solution 3: Use Claude Opus 4.6 (Updated March 2026)

The opus 4.6 model can generate 128,000 output tokens.
