Robust HTTP client for LLM providers with retries and error mapping.
// Source: https://github.com/MemTensor/MemOS | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* HTTP helpers for LLM providers.
*
* Similar in spirit to `core/embedding/fetcher.ts`, but LLM calls differ:
* - Retries on 5xx / 429 / transient network errors with exponential backoff.
* - Timeouts are per-call, not per-request, so streaming can take minutes.
* - Errors are mapped to `llm_unavailable` / `llm_rate_limited` /
* `llm_timeout` — the client cares which one it is.
* - A small SSE decoder is provided for providers that return
* `text/event-stream` (openai_compatible, anthropic).
*/
import { ERROR_CODES, MemosError } from "../../agent-contract/er
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key