{"record":{"id":"38958e0ea88edca5","repo":"continuedev/continue","slug":"asksage-api-error-response-status-response-s-38958e","errorCode":null,"errorMessage":"AskSage API error: ${response.status} ${response.statusText}: ${errText}","messagePattern":"AskSage API error: (.+?) (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/AskSage.ts","lineNumber":361,"sourceCode":"\n    try {\n      const headers = await this.getHeaders();\n      const response = await this.fetchFn(endpoint, {\n        method: \"POST\",\n        headers,\n        body: JSON.stringify(requestBody),\n        signal,\n      });\n\n      if (!response.ok) {\n        const errText = await response.text();\n\n        // Clear token cache on 401\n        if (response.status === 401) {\n          this.clearTokenCache();\n        }\n\n        throw new Error(\n          `AskSage API error: ${response.status} ${response.statusText}: ${errText}`,\n        );\n      }\n\n      const data = (await response.json()) as AskSageResponse;\n      return this.parseResponse(data, body.model);\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new Error(`AskSage client error: ${error.message}`);\n      }\n      throw error;\n    }\n  }\n\n  async *chatCompletionStream(\n    body: ChatCompletionCreateParamsStreaming,\n    signal: AbortSignal,\n  ): AsyncGenerator<ChatCompletionChunk> {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/AskSage.ts#L343-L379","documentation":"The non-streaming AskSage chat request returned an HTTP error status. The adapter throws with status, statusText, and the response body, and clears its cached token on 401 so the next call re-authenticates.","triggerScenarios":"AskSage returning 4xx/5xx from its chat endpoint: 401 invalid/expired token, 400 bad request (bad model name), 429 rate limit, 5xx outage.","commonSituations":"Expired session token after long idle; wrong model identifier; rate limiting under load; AskSage service degradation.","solutions":["Read the status in the message: 401→re-check apiKey/email (token cache is auto-cleared, retry once); 400→validate model/params; 429→back off and retry; 5xx→retry later","Verify the model name exists in AskSage docs","Add retry with exponential backoff for 429/5xx","If 401 persists, verify credentials via the token endpoint directly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check model name against AskSage docs before calling\nif (!ASKSAGE_MODELS.includes(body.model)) throw new Error(`Unknown model ${body.model}`);","typeGuard":null,"tryCatchPattern":"catch (e) {\n  const m = String(e);\n  if (/AskSage API error: 401/.test(m)) return await retryOnce();\n  if (/AskSage API error: 429|AskSage API error: 5\\d\\d/.test(m)) return await withBackoff(() => api.chatCompletionNonStream(body, signal));\n  throw e;\n}","preventionTips":["Implement exponential backoff for 429/5xx","On 401 let the auto-cleared token cache refresh, then retry once"],"tags":["asksage","http-error","api-status"],"backgroundTag":"api-request-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}