From b904eddc6914a95c86998d24ea7ce644a9cfcf70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Kujund=C5=BEi=C4=87?= <51266541+404oops@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:18:45 +0100 Subject: [PATCH] feat(ai): add GPT-6.2 Astra and Sol with API pricing (#4678) --- .../openaiCompatible/openaiParams.test.ts | 4 + .../openaiCompatible/openaiParams.ts | 2 +- .../OpenAiChatCompletionsProvider.test.ts | 2 + .../chat/OpenAiChatResponsesProvider.test.ts | 4 + .../ai/providers/openai/chat/models.test.ts | 74 +++++++++++++++++++ .../ai/providers/openai/chat/models.ts | 60 +++++++++++++++ src/docs/src/AI/chat.md | 6 +- src/docs/src/rate-limits-and-quotas.md | 2 +- 8 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 src/backend/drivers/ai/providers/openai/chat/models.test.ts diff --git a/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.test.ts b/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.test.ts index d6f81a8cf..31a316a4e 100644 --- a/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.test.ts +++ b/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.test.ts @@ -294,6 +294,10 @@ describe('clampReasoningEffort', () => { ['gpt-5.5', 'max', 'xhigh'], ['gpt-5', 'high', 'high'], ['gpt-6-astra-1', 'none', 'low'], + ...(['gpt-6.2-astra', 'gpt-6.2-sol'] as const).flatMap((id) => [ + [id, 'none', 'low'] as const, + [id, 'max', 'max'] as const, + ]), ...(['none', 'low', 'medium', 'high', 'xhigh', 'max'] as const).map( (effort) => ['gpt-6.1-terra', effort, effort] as const, ), diff --git a/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.ts b/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.ts index 78ef2fae0..0a37677a6 100644 --- a/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.ts +++ b/src/backend/drivers/ai/protocols/openaiCompatible/openaiParams.ts @@ -227,7 +227,7 @@ const REASONING_EFFORT_TABLE: { allowed: readonly ReasoningEffort[]; }[] = [ { - pattern: /^gpt-6-astra|^gpt-6\.1-sol/, + pattern: /^gpt-6-astra|^gpt-6\.1-sol|^gpt-6\.2-(astra|sol)/, allowed: ['low', 'medium', 'high', 'xhigh', 'max'], }, { diff --git a/src/backend/drivers/ai/providers/openai/chat/OpenAiChatCompletionsProvider.test.ts b/src/backend/drivers/ai/providers/openai/chat/OpenAiChatCompletionsProvider.test.ts index c7e01860a..42a702a1e 100644 --- a/src/backend/drivers/ai/providers/openai/chat/OpenAiChatCompletionsProvider.test.ts +++ b/src/backend/drivers/ai/providers/openai/chat/OpenAiChatCompletionsProvider.test.ts @@ -501,6 +501,8 @@ describe('OpenAiChatProvider.complete request shape', () => { it.each([ 'gpt-6-astra', 'gpt-6.1-sol', + 'gpt-6.2-sol', + 'gpt-6.2-astra', 'gpt-6.1-terra', 'gpt-6-sol', 'gpt-6-luna', diff --git a/src/backend/drivers/ai/providers/openai/chat/OpenAiChatResponsesProvider.test.ts b/src/backend/drivers/ai/providers/openai/chat/OpenAiChatResponsesProvider.test.ts index 42071c84f..c03fcc46e 100644 --- a/src/backend/drivers/ai/providers/openai/chat/OpenAiChatResponsesProvider.test.ts +++ b/src/backend/drivers/ai/providers/openai/chat/OpenAiChatResponsesProvider.test.ts @@ -337,6 +337,8 @@ describe('OpenAiResponsesChatProvider.complete request shape', () => { 'gpt-6-luna', 'gpt-6-astra', 'gpt-6.1-sol', + 'gpt-6.2-sol', + 'gpt-6.2-astra', 'gpt-6.1-terra', 'gpt-5.6', 'openai/gpt-5.6', @@ -629,6 +631,8 @@ describe('OpenAiResponsesChatProvider.complete request shape', () => { it.each([ 'gpt-6-astra', 'gpt-6.1-sol', + 'gpt-6.2-sol', + 'gpt-6.2-astra', 'gpt-6.1-terra', 'gpt-6-sol', 'gpt-6-luna', diff --git a/src/backend/drivers/ai/providers/openai/chat/models.test.ts b/src/backend/drivers/ai/providers/openai/chat/models.test.ts new file mode 100644 index 000000000..b2e937e2f --- /dev/null +++ b/src/backend/drivers/ai/providers/openai/chat/models.test.ts @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024-present Puter Technologies Inc. + * + * This file is part of Puter. + * + * Puter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { OPEN_AI_MODELS } from './models.js'; +import { selectServiceSpeed } from '../../../interfaces/chat/utils/serviceSpeed.js'; + +afterEach(() => vi.useRealTimers()); + +describe('GPT-6.2 catalog', () => { + it.each([ + ['gpt-6.2-astra', '2026-05-18', 800, 40, 4000], + ['gpt-6.2-sol', '2026-06-01', 200, 10, 1000], + ])('publishes %s with vendor pricing and capabilities', (id, knowledge, input, cached, output) => { + expect(OPEN_AI_MODELS.find((model) => model.id === id)).toMatchObject({ + puterId: `openai:openai/${id}`, + aliases: [`openai/${id}`], + knowledge, + responses_api: true, + responsesSampling: 'never', + tool_call: true, + modalities: { input: ['text', 'image'], output: ['text'] }, + context: 1_050_000, + max_tokens: 128_000, + costs_currency: 'usd-cents', + costs: { + tokens: 1_000_000, + prompt_tokens: input, + cached_tokens: cached, + cache_write_tokens: Number(input) * 1.25, + cache_write_12h_tokens: Number(input) * 2.5, + completion_tokens: output, + }, + long_context_pricing: { threshold: 272_000, input_multiplier: 2, output_multiplier: 1.5 }, + }); + }); + + it.each(['gpt-6.2-astra', 'gpt-6.2-sol'])('updates %s Ultrafast rates at the Pacific promotion boundary', (id) => { + const model = OPEN_AI_MODELS.find((entry) => entry.id === id)!; + vi.useFakeTimers(); + for (const [time, multiplier] of [ + ['2027-03-01T07:59:59.999Z', 3], + ['2027-03-01T08:00:00.000Z', 6], + ] as const) { + vi.setSystemTime(new Date(time)); + const selected = selectServiceSpeed(model, { + messages: [{ role: 'user', content: 'Hello' }], + serviceSpeed: 'ultrafast', + }, () => undefined); + expect(selected.speed).toBe('ultrafast'); + expect(selected.args.service_tier).toBe('ultrafast'); + for (const key of ['prompt_tokens', 'cached_tokens', 'cache_write_tokens', 'cache_write_12h_tokens', 'completion_tokens']) { + expect(selected.model.costs[key]).toBe(model.costs[key] * multiplier); + } + expect(selected.model.costs.tokens).toBe(1_000_000); + } + }); +}); diff --git a/src/backend/drivers/ai/providers/openai/chat/models.ts b/src/backend/drivers/ai/providers/openai/chat/models.ts index e85fd4621..d7a7fe9b1 100644 --- a/src/backend/drivers/ai/providers/openai/chat/models.ts +++ b/src/backend/drivers/ai/providers/openai/chat/models.ts @@ -31,8 +31,68 @@ const GPT_LONG_CONTEXT_PRICING = { output_multiplier: 1.5, }; +// OpenAI's Ultrafast promotion ends at midnight Pacific on March 1, 2027. +const GPT_62_SERVICE_SPEED_RATES = { + fast: 2, + get ultrafast() { + return Date.now() < Date.UTC(2027, 2, 1, 8) ? 3 : 6; + }, +}; + // Hardcoded from https://models.dev/api.json export const OPEN_AI_MODELS: IChatModel[] = [ + { + puterId: 'openai:openai/gpt-6.2-astra', + id: 'gpt-6.2-astra', + responsesSampling: 'never', + modalities: { input: ['text', 'image'], output: ['text'] }, + open_weights: false, + tool_call: true, + knowledge: '2026-05-18', + aliases: ['openai/gpt-6.2-astra'], + costs_currency: 'usd-cents', + input_cost_key: 'prompt_tokens', + output_cost_key: 'completion_tokens', + serviceSpeedRates: GPT_62_SERVICE_SPEED_RATES, + costs: { + tokens: 1_000_000, + prompt_tokens: 800, + cached_tokens: 40, + cache_write_tokens: 800 * 1.25, + cache_write_12h_tokens: 800 * 2.5, + completion_tokens: 4000, + }, + long_context_pricing: GPT_LONG_CONTEXT_PRICING, + context: 1_050_000, + max_tokens: 128_000, + responses_api: true, + }, + { + puterId: 'openai:openai/gpt-6.2-sol', + id: 'gpt-6.2-sol', + responsesSampling: 'never', + modalities: { input: ['text', 'image'], output: ['text'] }, + open_weights: false, + tool_call: true, + knowledge: '2026-06-01', + aliases: ['openai/gpt-6.2-sol'], + costs_currency: 'usd-cents', + input_cost_key: 'prompt_tokens', + output_cost_key: 'completion_tokens', + serviceSpeedRates: GPT_62_SERVICE_SPEED_RATES, + costs: { + tokens: 1_000_000, + prompt_tokens: 200, + cached_tokens: 10, + cache_write_tokens: 200 * 1.25, + cache_write_12h_tokens: 200 * 2.5, + completion_tokens: 1000, + }, + long_context_pricing: GPT_LONG_CONTEXT_PRICING, + context: 1_050_000, + max_tokens: 128_000, + responses_api: true, + }, { puterId: 'openai:openai/gpt-6.1-terra', id: 'gpt-6.1-terra', diff --git a/src/docs/src/AI/chat.md b/src/docs/src/AI/chat.md index fbfe21e2e..e63e0ff48 100755 --- a/src/docs/src/AI/chat.md +++ b/src/docs/src/AI/chat.md @@ -391,14 +391,16 @@ Passing `service_tier: "priority"` selects fast service, and `service_tier: "ult Input and reasoning tokens reported by a non-streaming Responses API call are billed even when its output is empty. These charges apply whether the request fails or retries another provider. -Fast service is available on models with a published Fast rate card. Ultrafast is available for GPT-6.1 Sol and GPT-6 Astra. Other models fall back to fast or standard. Cache and long-context rates apply to the served tier. +Fast service is available on models with a published Fast rate card. Ultrafast is available for GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Sol, and GPT-6 Astra. For GPT-6.2 Astra and Sol, Ultrafast costs 3 times Standard through February 28, 2027, and 6 times Standard starting March 1, 2027, Pacific time. Other models fall back to fast or standard. Cache and long-context rates apply to the served tier. #### `temperature` -Some OpenAI reasoning models ignore `temperature` and `top_p`. GPT-5.6, GPT-6 Sol/Luna, and GPT-6.1 Terra accept them only with `reasoning_effort: 'none'`, and GPT-6 Astra, GPT-6.1 Sol, and GPT-5.3 Codex always ignore them. +Some OpenAI reasoning models ignore `temperature` and `top_p`. GPT-5.6, GPT-6 Sol/Luna, and GPT-6.1 Terra accept them only with `reasoning_effort: 'none'`, and GPT-6 Astra, GPT-6.1 Sol, GPT-6.2 Astra/Sol, and GPT-5.3 Codex always ignore them. #### `reasoning_effort` +GPT-6.2 Astra and Sol accept `low`, `medium`, `high`, `xhigh`, and `max`. A requested `none` or `minimal` is clamped to `low`. + GPT-6.1 Terra accepts `none`, `low`, `medium` (default), `high`, `xhigh`, and `max`. #### Web Search diff --git a/src/docs/src/rate-limits-and-quotas.md b/src/docs/src/rate-limits-and-quotas.md index ecd8201aa..a4dc9c8b5 100644 --- a/src/docs/src/rate-limits-and-quotas.md +++ b/src/docs/src/rate-limits-and-quotas.md @@ -80,7 +80,7 @@ An input over its limit is rejected before it reaches the model, as is an image The standard chat timeout is 10 minutes for a response to start, or to finish if it isn't streamed. Stream durations depend on the provider. Native Gemini applies the 10-minute timeout to the whole response, including streaming. Groq uses 60 seconds to start a response. Mistral streams have no timeout of their own. If the caller disconnects, a stream that's still running gets 10 more minutes to finish, and is then stopped. See the [AI model directory](https://developer.puter.com/ai/models/) for model specifications. -GPT-6.1 Terra has a 1,050,000-token context window and a maximum output of 128,000 tokens. Requests with more than 272,000 input tokens are charged at twice the input and cache rates and 1.5 times the output rate for the whole request. +GPT-6.2 Astra, GPT-6.2 Sol, and GPT-6.1 Terra have a 1,050,000-token context window and a maximum output of 128,000 tokens. Requests with more than 272,000 input tokens are charged at twice the input and cache rates and 1.5 times the output rate for the whole request. Gemini 4 Carbon and Gemini 4 Hydrogen accept text and images within a shared 1,048,576-token window and generate up to 65,536 tokens, including thinking.