Skip to content

@ai-sdk/openai-compatible max_tokens error for GPT 5.x #5421

@junmediatek

Description

@junmediatek

Description

when I use @ai-sdk/openai-compatible to create a provider, and ues the GPT 5.x model, the body of the request contains max_tokens, not max_completion_tokens, so the LLM returned an error as below:

ERROR 2025-12-12T05:44:36 +2ms service=session.processor error=Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. stack="AI_APICallError: Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.\n at <anonymous> (/Users/mtk/AI_Coding/OSS/opencode/node_modules/.bun/@[email protected]+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:889:18)\n at processTicksAndRejections (native:7:39)" process

I find the ’max_tokens‘ is deprecated in the openai API reference for reasoning models.
https://platform.openai.com/docs/api-reference/chat/create#chat_create-max_tokens

My provider as below

"gaisf-openai-compatible": { "npm": "@ai-sdk/openai-compatible", "name": "gaisf-openai-compatible", "options": { "baseURL": "https://mlop-azure-gateway.xxxx.inc/v1", "apiKey": "{env:MY_GAISF_KEY}", "timeout": 300000 }, "models": { "gpt-5.1-high": { "id": "azure/gpt-5.1", "name": "gpt-5.1-high-test", "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] }, "options": { "reasoningEffort": "high" }, "limit": { "context": 400000, "output": 128000 }, "cost": { "input": 1.25, "output": 10, "cache_read": 0.13 } } }

@rekram1-node Could you help to check this issue?

OpenCode version

1.0.150

Steps to reproduce

use @ai-sdk/openai-compatible for gpt 5.x model to create provider

Screenshot and/or share link

NA

Operating System

ubuntu 24.4

Terminal

VSCode remoteSSH

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions