Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

462 B
Raw Blame
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null;

export const streamErrorMessage = (frame: unknown): string | null => {
  if (!isRecord(frame) || !frame.error) {
    return null;
  }
  const { error } = frame;
  if (typeof error === "string") {
    return error;
  }
  if (isRecord(error) && typeof error.message === "string") {
    return error.message;
  }
  return JSON.stringify(error);
};