Skip to content

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

Closed

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.

Activity

  1. github-actions commented on May 14, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. nexxeln commented on May 18, 2026

    @nexxeln
    Contributor

    Thanks for the detailed report. I do not think this is actionable in stock OpenCode as written.

    What I checked:

    • Current OpenAI Responses API docs explicitly show gpt-5.5 accepting max_output_tokens.
    • OpenCode built-in OpenAI/Codex plugin already clears output.maxOutputTokens for provider openai to match Codex CLI behavior, so stock OpenCode should not send max_output_tokens on that path. This is present in v1.14.50 and current dev.
    • We have a regression assertion for the OpenAI Responses payload that expects max_output_tokens to be absent, and that focused test passes locally.

    Given the workaround says removing @iam-brain/opencode-codex-auth fixes it, this looks like the third-party plugin is either reintroducing the cap after OpenCode built-in hook or running a custom request path. If you can reproduce this with stock OpenCode, default plugins enabled, and no third-party Codex auth plugin, please reopen with the raw request body and startup flags/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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