feat: add useResponsesApi option to opt out of Responses API (#11809)
* 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
This commit is contained in:
parent
902289e183
commit
15ea93dae0
10 changed files with 86 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -131,3 +131,37 @@ To force usage of `completions` instead of `chat/completions` endpoint you can s
|
|||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### 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:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="YAML">
|
||||
```yaml title="config.yaml"
|
||||
name: My Config
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
|
||||
models:
|
||||
- name: gpt-5
|
||||
provider: openai
|
||||
model: gpt-5
|
||||
useResponsesApi: false
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="JSON (Deprecated)">
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "gpt-5",
|
||||
"provider": "openai",
|
||||
"model": "gpt-5",
|
||||
"useResponsesApi": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue