Utility functions for building OpenAI endpoints, headers, and handling request errors in LLM providers.
// Source: https://github.com/mcp-use/mcp-use | License: MIT | Copyright 2025 pietrozullo
// Provided via justclaw.it.com; keep this notice with the code.
import type { ProviderConfig } from "../types.js";
const OPENAI_BASE_URL = "https://api.openai.com/v1";
/** HTTP error returned by an LLM provider request. */
export class LlmRequestError extends Error {
/** HTTP response status. */
readonly status: number;
/** Parsed JSON response body, or the raw response text. */
readonly body?: unknown;
/**
* @param status - HTTP response status.
* @param message - Error message.
* @param body - Parsed or raw provider response body.
*/
constructor(status: number, message: string, body?: unknown) {
super(message);
this.name = "LlmRequestError";
this.status = stat
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key