diff --git a/.changeset/gpt5-support.md b/.changeset/gpt5-support.md new file mode 100644 index 0000000000..173d60899c --- /dev/null +++ b/.changeset/gpt5-support.md @@ -0,0 +1,11 @@ +--- +"@roo-code/types": minor +"roo-cline": minor +--- + +Add GPT-5 model support + +- Added GPT-5 models (gpt-5-2025-08-07, gpt-5-mini-2025-08-07, gpt-5-nano-2025-08-07) to OpenAI Native provider +- Added nectarine-alpha-new-reasoning-effort-2025-07-25 experimental model +- Set gpt-5-2025-08-07 as the new default OpenAI Native model +- Implemented GPT-5 specific handling with streaming and reasoning effort support diff --git a/packages/types/src/providers/openai.ts b/packages/types/src/providers/openai.ts index 0afdd46feb..027ee17f1a 100644 --- a/packages/types/src/providers/openai.ts +++ b/packages/types/src/providers/openai.ts @@ -3,9 +3,45 @@ import type { ModelInfo } from "../model.js" // https://openai.com/api/pricing/ export type OpenAiNativeModelId = keyof typeof openAiNativeModels -export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-4.1" +export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-5-2025-08-07" export const openAiNativeModels = { + "gpt-5-2025-08-07": { + maxTokens: 128000, + contextWindow: 256000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 1.25, + outputPrice: 10.0, + cacheReadsPrice: 0.125, + }, + "gpt-5-mini-2025-08-07": { + maxTokens: 128000, + contextWindow: 256000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.25, + outputPrice: 2.0, + cacheReadsPrice: 0.025, + }, + "gpt-5-nano-2025-08-07": { + maxTokens: 128000, + contextWindow: 256000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.05, + outputPrice: 0.4, + cacheReadsPrice: 0.005, + }, + "nectarine-alpha-new-reasoning-effort-2025-07-25": { + maxTokens: 128000, + contextWindow: 256000, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0, + outputPrice: 0, + cacheReadsPrice: 0, + }, "gpt-4.1": { maxTokens: 32_768, contextWindow: 1_047_576, diff --git a/src/api/providers/openai-native.ts b/src/api/providers/openai-native.ts index 3f14e65cc6..c9913406a5 100644 --- a/src/api/providers/openai-native.ts +++ b/src/api/providers/openai-native.ts @@ -53,6 +53,8 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio yield* this.handleReasonerMessage(model, id, systemPrompt, messages) } else if (model.id.startsWith("o1")) { yield* this.handleO1FamilyMessage(model, systemPrompt, messages) + } else if (this.isGPT5Model(model.id)) { + yield* this.handleGPT5Message(model, systemPrompt, messages) } else { yield* this.handleDefaultModelMessage(model, systemPrompt, messages) } @@ -123,6 +125,26 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio yield* this.handleStreamResponse(stream, model) } + private async *handleGPT5Message( + model: OpenAiNativeModel, + systemPrompt: string, + messages: Anthropic.Messages.MessageParam[], + ): ApiStream { + const stream = await this.client.chat.completions.create({ + model: model.id, + temperature: 1, + messages: [{ role: "developer", content: systemPrompt }, ...convertToOpenAiMessages(messages)], + stream: true, + stream_options: { include_usage: true }, + }) + + yield* this.handleStreamResponse(stream, model) + } + + private isGPT5Model(modelId: string): boolean { + return modelId.includes("gpt-5") || modelId.includes("gpt5") || modelId.includes("nectarine") + } + private async *handleStreamResponse( stream: AsyncIterable, model: OpenAiNativeModel,