Zod schemas for validating OpenAI chat request and message structures.
// Source: https://github.com/mhrsdev/Zero-router | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from "zod";
/**
* Wire schemas for the OpenAI Chat Completions dialect.
*
* These are deliberately permissive on input: clients send fields we do not
* model, and rejecting an unknown key would break SDKs the moment OpenAI ships
* a new parameter. Unknown keys are collected, not fatal.
*/
const imageUrlSchema = z.object({
url: z.string(),
detail: z.enum(["low", "high", "auto"]).optional(),
});
export const openAIContentPartSchema = z.union([
z.object({ type: z.literal("text"), text: z.string() }),
z.object({ type: z.literal("image_url"), image_url: imageU
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key