From 15ea93dae0414515010a2317959e39cdbabae693 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 25 Mar 2026 16:09:46 -0700 Subject: [PATCH] feat: add `useResponsesApi` option to opt out of Responses API (#11809) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add `useResponsesApi` option to allow opting out of OpenAI Responses API Add a `useResponsesApi` config option that, when set to false, forces o-series and gpt-5 models to use /chat/completions instead of /responses. This helps users whose organizations are not verified avoid "organization must be verified" errors related to reasoning summaries and streaming. The option gates both code paths where the Responses API is selected: - `canUseOpenAIResponses()` in BaseLLM (native path) - `shouldUseResponsesEndpoint()` in the OpenAI adapter Closes #11772 Related: #8209, #7129 * feat: suggest `useResponsesApi: false` in org verification error messages Update error detection to also catch "organization must be verified to stream" errors (in addition to reasoning summaries), and update the error message to suggest adding `useResponsesApi: false` to model config as a workaround. * fix: improve org verification error message copy * fix: add useResponsesApi to LLMOptions in index.d.ts The actual type definitions used by tsc are in core/index.d.ts, not in the string template in config/types.ts. * fix: also check provider name when detecting org verification errors The error message from OpenAI's API doesn't always contain the word "openai" — check the provider name from the model config as well. * feat: detect missing authentication header error and suggest adding apiKey * fix: handle missing auth error directly in 401 dialog block The 401 status code handler in StreamError.tsx renders before the customErrorMessage check, so detect the missing authentication error inline within the 401 block. * Revert "fix: handle missing auth error directly in 401 dialog block" This reverts commit 0053957d2df7c64ddea2279982f5e07e2cee1020. * style: fix prettier formatting in index.d.ts * style: revert unrelated prettier reformatting in index.d.ts * fix: handle undefined providerName in error analysis * fix: use YAML-style formatting in useResponsesApi suggestion --- core/config/types.ts | 11 +++++- core/index.d.ts | 2 ++ core/llm/index.ts | 2 ++ .../model-providers/top-level/openai.mdx | 34 +++++++++++++++++++ extensions/vscode/config_schema.json | 4 +++ gui/src/util/errorAnalysis.test.ts | 16 +++++++-- gui/src/util/errorAnalysis.ts | 21 +++++++++--- packages/config-yaml/src/schemas/models.ts | 1 + packages/openai-adapters/src/apis/OpenAI.ts | 3 ++ packages/openai-adapters/src/types.ts | 1 + 10 files changed, 86 insertions(+), 9 deletions(-) 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"),