openaiError (http/openai-errors.ts)

atomic-agent · src/http/openai-errors.ts · typescript · MIT
ai

Creates a standardized OpenAI‑style error payload for non‑2xx HTTP responses.

// Source: https://github.com/AtomicBot-ai/atomic-agent | License: MIT | Copyright 2026 Atomic Bot
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * OpenAI-style error envelope. Mirrors hermes-agent `_openai_error` so
 * existing OpenAI SDKs surface the same shape. Used for every non-2xx
 * response emitted by the HTTP server — including atomic-specific
 * endpoints — to keep the error schema uniform across the whole surface.
 */
export interface OpenAiErrorPayload {
  error: {
    message: string;
    type: string;
    param: string | null;
    code: string | null;
  };
}

export function openaiError(
  message: string,
  type = "invalid_request_error",
  param: string | null = null,
  code: string | null = null,
): OpenAiErrorPayload {
  return {
    error: {
      

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key