Skip to content

Commit d523354

Browse files
Fix token param handling for official GPT-5 model IDs
Apply max_completion_tokens only to official GPT-5 model IDs. Keep provider-prefixed names such as openai/gpt-5.2 on the max_tokens path so namespaced model IDs are not treated as official OpenAI GPT-5 identifiers.
1 parent fade0ea commit d523354

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/services/apis/openai-token-params.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const GPT5_CHAT_COMPLETIONS_MODEL_PATTERN = /(^|\/)gpt-5([.-]|$)/
1+
const GPT5_CHAT_COMPLETIONS_MODEL_PATTERN = /^gpt-5([.-]|$)/
22

33
function shouldUseMaxCompletionTokens(provider, model) {
44
const normalizedProvider = String(provider || '').toLowerCase()

tests/unit/services/apis/openai-token-params.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ test('uses max_completion_tokens for gpt-5.x chat models', () => {
88
})
99
})
1010

11-
test('uses max_completion_tokens for provider-prefixed gpt-5.x models', () => {
11+
test('uses max_tokens for provider-prefixed gpt-5.x model names', () => {
1212
assert.deepEqual(getChatCompletionsTokenParams('openai', 'openai/gpt-5.2', 2048), {
13-
max_completion_tokens: 2048,
13+
max_tokens: 2048,
1414
})
1515
})
1616

0 commit comments

Comments
 (0)