← sources

Ollama with Claude Code keeps hitting output token maximum.

source: reddit (reddit:ollama)published 2026-10-13 01:57ingested 2026-10-14 02:42

retained text

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

I've been getting this error constantly while trying to use Ollama with Claude. Everywhere I look, I'm just told to change the CLAUDE_CODE_MAX_OUTPUT_TOKENS. But I've tried it big and I've tried it small but it still gets overrun when I try to do any kind of coding.

Does anyone familiar with using Claude with Ollama know how to workaround this issue?

I'm currently using "gpt-oss:20b" model but this has occurred with every model I've tried so far.

document fetched 2026-10-14 00:41 · canonical https://reddit.com/r/ollama/comments/1x4kd2a/ollama_with_claude_code_keeps_hitting_output