Skip to content

GPT-5.5 on Responses API rejects max_output_tokens: Bad Request error #27547

Description

@apereiracvo

Bug

When using GPT-5.5 through the Responses API (via @iam-brain/opencode-codex-auth plugin or native OpenAI provider), OpenCode sends max_output_tokens: 32000 in the request body. The OpenAI Responses API for GPT-5.5 rejects this parameter with a Bad Request error:

"max_output_tokens" not permitted

Root Cause

From the logs, the request to https://api.openai.com/v1/responses includes:

"max_output_tokens": 32000

GPT-5.5 (and other reasoning models on the Responses API) do not accept max_output_tokens. They use reasoningEffort and textVerbosity instead. OpenCode is automatically injecting this from the model's known output limit.

Environment

  • OpenCode v1.14.50 (also fails on v1.14.49)
  • Model: openai/gpt-5.5
  • Provider: OpenAI (Responses API)
  • Plugin: @iam-brain/opencode-codex-auth@1.7.1

Workarounds Tried

  1. ✅ Upgraded OpenCode to v1.14.50 — still fails
  2. ✅ Updated @iam-brain/opencode-codex-auth to v1.7.1 — still fails
  3. ✅ Set sanitizeInputs: true in codex-config.jsonc — still fails
  4. ✅ Added model options (reasoningEffort, textVerbosity, reasoningSummary) in opencode.json — still fails
  5. ✅ Removed plugin (fixes the error but loses OAuth subscription access)

Expected Behavior

OpenCode should NOT send max_output_tokens for reasoning models (GPT-5.x) when using the Responses API. The parameter should be omitted or replaced with the appropriate reasoning model controls (reasoningEffort, textVerbosity).

Suggested Fix

When the provider is OpenAI and the model is a reasoning model (GPT-5.x), OpenCode should:

  1. Omit max_output_tokens from the request body
  2. Use reasoningEffort and textVerbosity instead (already configurable via model options)

Alternatively, allow users to configure limit.output or a flag to disable sending max_output_tokens for specific models.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions