diff --git a/core/config/types.ts b/core/config/types.ts index d9f58aca6..8c64de1ab 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -534,7 +534,16 @@ declare global { cacheBehavior?: CacheBehavior; useLegacyCompletionsEndpoint?: boolean; - + + /** + * When set to false, forces the OpenAI provider to use the /chat/completions + * endpoint instead of the /responses endpoint for o-series and gpt-5 models. + * This can help avoid "organization must be verified" errors related to + * reasoning summaries and streaming on the Responses API. + * Defaults to true for official OpenAI API. + */ + useResponsesApi?: boolean; + // Embedding options embeddingId?: string; maxEmbeddingChunkSize?: number; diff --git a/core/index.d.ts b/core/index.d.ts index 068c51abc..1149da743 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -677,6 +677,7 @@ export interface LLMOptions { roles?: ModelRole[]; useLegacyCompletionsEndpoint?: boolean; + useResponsesApi?: boolean; // Embedding options embeddingId?: string; @@ -1737,6 +1738,7 @@ export interface JSONModelDescription { accountId?: string; aiGatewaySlug?: string; useLegacyCompletionsEndpoint?: boolean; + useResponsesApi?: boolean; deploymentId?: string; isFromAutoDetect?: boolean; } diff --git a/core/llm/index.ts b/core/llm/index.ts index 08d23442e..dae5be6e4 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -329,6 +329,7 @@ export abstract class BaseLLM implements ILLM { apiBase: this.apiBase, requestOptions: this.requestOptions, env: this._llmOptions.env, + useResponsesApi: this._llmOptions.useResponsesApi, }); } @@ -1045,6 +1046,7 @@ export abstract class BaseLLM implements ILLM { private canUseOpenAIResponses(options: CompletionOptions): boolean { return ( this.providerName === "openai" && + this._llmOptions.useResponsesApi !== false && typeof (this as any)._streamResponses === "function" && (this as any).isOSeriesOrGpt5Model(options.model) ); diff --git a/docs/customize/model-providers/top-level/openai.mdx b/docs/customize/model-providers/top-level/openai.mdx index e991e487f..4d7326b47 100644 --- a/docs/customize/model-providers/top-level/openai.mdx +++ b/docs/customize/model-providers/top-level/openai.mdx @@ -131,3 +131,37 @@ To force usage of `completions` instead of `chat/completions` endpoint you can s ``` + +### How to Disable the Responses API + +By default, Continue uses OpenAI's `/responses` endpoint for o-series and gpt-5 models. If you encounter "organization must be verified" errors related to reasoning summaries or streaming, you can force the use of `/chat/completions` instead: + + + + ```yaml title="config.yaml" + name: My Config + version: 0.0.1 + schema: v1 + + models: + - name: gpt-5 + provider: openai + model: gpt-5 + useResponsesApi: false + ``` + + + ```json title="config.json" + { + "models": [ + { + "title": "gpt-5", + "provider": "openai", + "model": "gpt-5", + "useResponsesApi": false + } + ] + } + ``` + + diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 0b9811c9e..5bdee801d 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1497,6 +1497,10 @@ "properties": { "useLegacyCompletionsEndpoint": { "type": "boolean" + }, + "useResponsesApi": { + "type": "boolean", + "description": "When set to false, forces the use of /chat/completions instead of the /responses endpoint for o-series and gpt-5 models. This can help avoid 'organization must be verified' errors related to reasoning summaries and streaming." } } } diff --git a/gui/src/util/errorAnalysis.test.ts b/gui/src/util/errorAnalysis.test.ts index 7ac1678fe..9928947db 100644 --- a/gui/src/util/errorAnalysis.test.ts +++ b/gui/src/util/errorAnalysis.test.ts @@ -533,7 +533,7 @@ describe("errorAnalysis", () => { }); describe("custom error detection", () => { - it("should detect OpenAI organization verification error", () => { + it("should detect OpenAI organization verification error for reasoning summaries", () => { const error = new Error( "OpenAI error: organization must be verified to generate reasoning summaries", ); @@ -542,9 +542,19 @@ describe("errorAnalysis", () => { expect(result.helpUrl).toBe( "https://help.openai.com/en/articles/10910291-api-organization-verification", ); - expect(result.customErrorMessage).toContain( - "organization must be verified", + expect(result.customErrorMessage).toContain("useResponsesApi"); + }); + + it("should detect OpenAI organization verification error for streaming", () => { + const error = new Error( + "OpenAI error: organization must be verified to stream this model", ); + const result = analyzeError(error, null); + + expect(result.helpUrl).toBe( + "https://help.openai.com/en/articles/10910291-api-organization-verification", + ); + expect(result.customErrorMessage).toContain("useResponsesApi"); }); it("should detect OpenAI org verification error case-insensitively", () => { diff --git a/gui/src/util/errorAnalysis.ts b/gui/src/util/errorAnalysis.ts index b022a5d1d..b04356490 100644 --- a/gui/src/util/errorAnalysis.ts +++ b/gui/src/util/errorAnalysis.ts @@ -106,17 +106,21 @@ export function analyzeError( const lowerParsedError = parsedError.toLowerCase(); const errorText = lowerMessage + " " + lowerParsedError; - // OpenAI organization verification error + // OpenAI organization verification error (reasoning summaries or streaming) + const isOpenAI = + errorText.includes("openai") || + (providerName ?? "").toLowerCase().includes("openai"); if ( - errorText.includes("openai") && - errorText.includes( + isOpenAI && + (errorText.includes( "organization must be verified to generate reasoning summaries", - ) + ) || + errorText.includes("organization must be verified to stream")) ) { helpUrl = "https://help.openai.com/en/articles/10910291-api-organization-verification"; customErrorMessage = - "Your OpenAI organization must be verified to use reasoning models. Visit the help page to learn how to verify your organization."; + "Your OpenAI organization must be verified for this feature. To avoid this, add `useResponsesApi: false` to your model config to use the /chat/completions endpoint instead, or verify your organization via the help page."; } // Invalid API key detection @@ -138,6 +142,13 @@ export function analyzeError( } } + // Missing authentication header (no API key configured) + if (errorText.includes("missing bearer or basic authentication")) { + helpUrl = "https://docs.continue.dev/reference#models"; + customErrorMessage = + 'No API key was sent with the request. Add "apiKey" to your model config.'; + } + // 402 Insufficient Balance if (statusCode === 402 || errorText.includes("insufficient balance")) { const providerLabel = providerName || "your provider"; diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index 737f6c67f..ee20d5a05 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -191,6 +191,7 @@ const baseModelFields = { chatOptions: chatOptionsSchema.optional(), promptTemplates: promptTemplatesSchema.optional(), useLegacyCompletionsEndpoint: z.boolean().optional(), + useResponsesApi: z.boolean().optional(), env: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) .optional(), diff --git a/packages/openai-adapters/src/apis/OpenAI.ts b/packages/openai-adapters/src/apis/OpenAI.ts index 6734e1c48..e41c590ec 100644 --- a/packages/openai-adapters/src/apis/OpenAI.ts +++ b/packages/openai-adapters/src/apis/OpenAI.ts @@ -78,6 +78,9 @@ export class OpenAIApi implements BaseLlmApi { } protected shouldUseResponsesEndpoint(model: string): boolean { + if (this.config.useResponsesApi === false) { + return false; + } const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/"; return isOfficialOpenAIAPI && isResponsesModel(model); } diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index 87dff3104..900ce7af8 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -30,6 +30,7 @@ export const BasePlusConfig = BaseConfig.extend({ // OpenAI and compatible export const OpenAIConfigSchema = BasePlusConfig.extend({ + useResponsesApi: z.boolean().optional(), provider: z.union([ z.literal("openai"), z.literal("mistral"),