Skip to content

Azure GPT-5 model: "max_tokens" parameter not supported, need "max_completion_tokens" instead #22623

Closed as not planned

Description

@hueifeng

Description

Bug Description

Using Azure GPT-5 model with opencode fails with error:
"Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead."

Environment

  • opencode version: 1.4.5
  • Model: gpt-5.4 (Azure deployment)
  • Provider: Azure OpenAI

Expected Behavior

Should be compatible with Azure GPT-5 API which requires max_completion_tokens instead of max_tokens

Possible Fix

Replace all occurrences of max_tokens with max_completion_tokens in the Azure OpenAI SDK integration, similar to how newer OpenAI API versions handle this parameter.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Apr 15, 2026

    @github-actions
    Contributor

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

    Please review these issues to see if your problem is already tracked, and if so, consider adding any additional context there.

  2. kobicovaldev commented on Apr 15, 2026

    @kobicovaldev
    Contributor

    Similar to what I am seeing here #22374

  3. self-assigned this
    on Apr 23, 2026
  4. refex commented on Apr 28, 2026

    @refex

    I solved it using this config

    {
      "$schema": "https://opencode.ai/config.json",
      "model": "azure-foundry/gpt-5.4-2",
      "theme": "opencode",
      "autoupdate": true,
      "provider": {
        "azure-foundry": {
          "type": "openai-compatible",
          "options": {
            "apiKey": "<api-key>",
            "baseURL": "https://myfoundry.services.ai.azure.com/api/projects/myfoundryproject/openai/v1"
          },
          "models": {
            "gpt-5.4-2": {
              "name": "gpt-5.4-2",
              "limit": { "context": 128000, "output": 16000 }
            }
          }
        }
      }
    }

    and a custom opencode plugin

    export const AzureFix = async () => {
      return {
        "chat.params": async (input, output) => {
          output.maxOutputTokens = undefined
        },
      }
    }
  5. removed
    bugSomething isn't working
    on May 3, 2026
  6. ArchiTecCTT commented on Jun 18, 2026

    @ArchiTecCTT

    Related: filed a cloudflare-ai-gateway-specific report in #32776 (built-in provider + pi-ai detectCompat forces max_tokens for all gateway traffic; opencode.jsonc compat overrides ignored).

  7. github-actions commented on Aug 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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