axValidateChatRequestMessage Generated TypeScript API reference. typescript api api/reference build/apidocs/Function.axValidateChatRequestMessage.md function axValidateChatRequestMessage

axValidateChatRequestMessage

TypeScript
function axValidateChatRequestMessage(item: 
  | {
  cache?: boolean;
  content: string;
  role: "system";
}
  | {
  cache?: boolean;
  content:   | string
     | (
     | {
     cache?: boolean;
     text: string;
     type: "text";
   }
     | {
     altText?: string;
     cache?: boolean;
     details?: "high" | "low" | "auto";
     image: string;
     mimeType: string;
     optimize?: "auto" | "quality" | "size";
     type: "image";
   }
     | {
     cache?: boolean;
     channels?: number;
     data: string;
     duration?: number;
     format?: AxAudioFormat;
     mimeType?: string;
     sampleRate?: number;
     transcription?: string;
     type: "audio";
   }
     | {
     cache?: boolean;
     data: string;
     extractedText?: string;
     filename?: string;
     mimeType: string;
     type: "file";
   }
     | {
     cache?: boolean;
     extractedText?: string;
     filename?: string;
     fileUri: string;
     mimeType: string;
     type: "file";
   }
     | {
     cache?: boolean;
     cachedContent?: string;
     description?: string;
     title?: string;
     type: "url";
     url: string;
   })[];
  name?: string;
  role: "user";
}
  | {
  audio?: {
     id: string;
     transcript?: string;
  };
  cache?: boolean;
  content?: string;
  functionCalls?: object[];
  name?: string;
  role: "assistant";
  thought?: string;
  thoughtBlocks?: AxThoughtBlockItem[];
}
  | {
  cache?: boolean;
  content?: AxFunctionResultContent;
  functionId: string;
  isError?: boolean;
  protocolResult?: {
     protocol: NonNullable<
        | undefined
        | {
        annotations?: Record<string, unknown>;
        kind: "mcp";
        meta?: Record<string, unknown>;
        name: string;
        namespace: string;
      }
        | {
        kind: "ucp";
        meta?: Record<string, unknown>;
        name: string;
        namespace: string;
     }>;
     value: unknown;
  };
  result: string;
  role: "function";
}): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/ai/validate.ts#L37

Validates a chat request message item to ensure it meets the required criteria

Parameters

ParameterTypeDescription
item| { cache?: boolean; content: string; role: "system"; } | { cache?: boolean; content: | string | ( | { cache?: boolean; text: string; type: "text"; } | { altText?: string; cache?: boolean; details?: "high" | "low" | "auto"; image: string; mimeType: string; optimize?: "auto" | "quality" | "size"; type: "image"; } | { cache?: boolean; channels?: number; data: string; duration?: number; format?: AxAudioFormat; mimeType?: string; sampleRate?: number; transcription?: string; type: "audio"; } | { cache?: boolean; data: string; extractedText?: string; filename?: string; mimeType: string; type: "file"; } | { cache?: boolean; extractedText?: string; filename?: string; fileUri: string; mimeType: string; type: "file"; } | { cache?: boolean; cachedContent?: string; description?: string; title?: string; type: "url"; url: string; })[]; name?: string; role: "user"; } | { audio?: { id: string; transcript?: string; }; cache?: boolean; content?: string; functionCalls?: object[]; name?: string; role: "assistant"; thought?: string; thoughtBlocks?: AxThoughtBlockItem[]; } | { cache?: boolean; content?: AxFunctionResultContent; functionId: string; isError?: boolean; protocolResult?: { protocol: NonNullable< | undefined | { annotations?: Record<string, unknown>; kind: "mcp"; meta?: Record<string, unknown>; name: string; namespace: string; } | { kind: "ucp"; meta?: Record<string, unknown>; name: string; namespace: string; }>; value: unknown; }; result: string; role: "function"; }The chat request message to validate

Returns

void

Throws

When validation fails with a descriptive error message

Docs