{"record":{"id":"ef772b887b399d7a","repo":"nexu-io/open-design","slug":"anthropic-resp-status-await-resp-text-catc","errorCode":null,"errorMessage":"anthropic ${resp.status}: ${await resp.text().catch(() => '')}","messagePattern":"anthropic (.+?): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/memory-llm.ts","lineNumber":802,"sourceCode":"      method: 'POST',\n      headers: {\n        'content-type': 'application/json',\n        'x-api-key': provider.apiKey,\n        'anthropic-version': '2023-06-01',\n      },\n      body: JSON.stringify({\n        model: provider.model,\n        max_tokens: 1024,\n        system,\n        messages: [{ role: 'user', content: user }],\n      }),\n      signal: withTimeout(FETCH_TIMEOUT_MS),\n    });\n  } catch (err) {\n    throw new Error(describeFetchError(err));\n  }\n  if (!resp.ok) {\n    throw new Error(`anthropic ${resp.status}: ${await resp.text().catch(() => '')}`);\n  }\n  const json = await resp.json();\n  const block = (json?.content || []).find((b) => b?.type === 'text');\n  return block?.text ?? '';\n}\n\nasync function callOpenAI(provider, system, user) {\n  let resp;\n  try {\n    resp = await fetch(\n      appendVersionedApiPath(provider.baseUrl, '/chat/completions'),\n      {\n        method: 'POST',\n        headers: {\n          'content-type': 'application/json',\n          // Keyless BYOK endpoints (local vLLM / Ollama / openai-compatible\n          // servers marked with `requiresApiKey: false`) accept requests\n          // without an Authorization header — sending `Bearer ` (empty)","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/memory-llm.ts#L784-L820","documentation":"The Anthropic Messages API returned a non-2xx HTTP status during the memory-LLM extraction call. The error includes the status code and the raw response body for diagnosis. This is the callAnthropic path in the daemon's automatic memory extractor, not the main chat runtime.","triggerScenarios":"Invalid or expired API key (401/403); rate limiting (429); model name not available on the account; request payload malformed; quota or billing exceeded; network-level error page returned instead of JSON.","commonSituations":"API key revoked or rotated without updating daemon config; wrong baseUrl pointing to a non-Anthropic endpoint; model deprecated or not enabled for the key; hitting rate limits during batch memory extraction; billing issues.","solutions":["Check the API key is valid, has credits, and is correctly configured in the memory provider settings","Verify provider.model is a current Anthropic model name available on the account","Confirm provider.baseUrl points to the correct Anthropic endpoint","Inspect the response body in the error message for the specific API error code","Retry after a delay if the status is 429 (rate limited)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const text = await callAnthropic(provider, system, user);\n} catch (err) {\n  if (err.message.startsWith('anthropic ')) {\n    const status = parseInt(err.message.split(' ')[1], 10);\n    if (status === 429) {\n      // Rate limited — retry with backoff\n      await sleep(backoffMs);\n      return callAnthropic(provider, system, user);\n    }\n    if (status === 401 || status === 403) {\n      throw new Error('Anthropic API key is invalid or lacks permission');\n    }\n  }\n  throw err;\n}","preventionTips":["Regularly verify API key validity and quota in the Anthropic console","Set provider.model to a currently available model — deprecated models return errors","Verify provider.baseUrl points to the official Anthropic endpoint or a compatible proxy","Implement exponential backoff for 429 rate-limit responses"],"tags":["anthropic","llm","http","memory-extraction","network"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}