Skip to content

Function: chatContentToText()

chatContentToText(content, options?): string

Flatten a message content value to plain text. Accepts the string form and structured content as either one ChatContentPart or an array, and yields "" for anything else (null, a lone image part, a malformed payload). Typed as unknown because most callers are reading a just-parsed JSON body, and the point of this helper is that they do not have to pre-check it.

unknown

string = ...

string[] = ...

string