/** * Zod schemas for the OpenAI chat-completions request shape we accept on the * gateway. Mirrors https://platform.openai.com/docs/api-reference/chat — only * the shapes the gateway translation layer understands. Unknown fields on * permissive objects are accepted-and-stripped (via `z.unknown()` passthroughs * or `.loose()`) so the official OpenAI SDK — which sends a growing pile of * non-strict defaults (e.g. `stream_options.include_obfuscation`) — does not * trip 400s on shapes we simply ignore. */ import type { ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionTool, ChatCompletionToolChoiceOption } from "openai/resources/chat/completions"; import * as z from "zod/v4"; export declare const textPartSchema: z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, z.core.$strip>; /** * OpenAI documents `image_url` as either `{ url: string, detail?: ... }` or — * older clients — a bare string. Accept both shapes; downstream we extract a * URL. `detail` is accepted for forward-compat but currently dropped (pi-ai's * `ImageContent` has no detail field — TODO: plumb through if/when added). */ export declare const imagePartSchema: z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>; /** OpenAI audio input block (gpt-4o-audio). Accepted; currently dropped downstream. */ export declare const inputAudioPartSchema: z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>; /** OpenAI file input block (file_search / vision-document). Accepted; currently dropped downstream. */ export declare const filePartSchema: z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>; /** Replayed assistant refusal block. Accepted; currently dropped downstream. */ export declare const refusalPartSchema: z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>; /** * Forward-compat catch-all for unknown content-part types. Matches every other * `{ type: string, ... }` object so a new OpenAI block kind does not 400 the * whole request; the walker ignores parts whose `type` it does not know. */ export declare const unknownPartSchema: z.ZodObject<{ type: z.ZodString; }, z.core.$loose>; export declare const userContentPartSchema: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>; export declare const toolCallSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodOptional>; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; export declare const toolSchema: z.ZodObject<{ type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; parameters: z.ZodOptional>; strict: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>; export declare const toolChoiceSchema: z.ZodUnion, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{ type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool">; name: z.ZodString; }, z.core.$strip>]>; export declare const systemMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"system">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>; export declare const developerMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"developer">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>; export declare const userMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>; export declare const assistantMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_calls: z.ZodOptional>; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; }, z.core.$strip>>>; }, z.core.$strip>; export declare const toolMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"tool">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_call_id: z.ZodOptional; }, z.core.$strip>; /** * Legacy `function` role (pre-tools API). Translated to a `tool` role * canonical message in the walker so downstream providers see one shape. */ export declare const functionMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"function">; name: z.ZodString; content: z.ZodNullable; }, z.core.$strip>; export declare const messageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ role: z.ZodLiteral<"system">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"developer">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_calls: z.ZodOptional>; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; }, z.core.$strip>>>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"tool">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_call_id: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"function">; name: z.ZodString; content: z.ZodNullable; }, z.core.$strip>], "role">; /** * Permissive: the official OpenAI SDK sets `include_obfuscation: false` by * default. We only consume `include_usage`, so unknown keys are silently * stripped rather than 400'd. */ export declare const streamOptionsSchema: z.ZodObject<{ include_usage: z.ZodOptional; }, z.core.$strip>; export declare const stopSchema: z.ZodUnion]>; export declare const openaiChatRequestSchema: z.ZodObject<{ model: z.ZodString; messages: z.ZodArray; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"developer">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_calls: z.ZodOptional>; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; }, z.core.$strip>>>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"tool">; content: z.ZodOptional; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image_url">; image_url: z.ZodUnion>; }, z.core.$strip>]>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_audio">; input_audio: z.ZodObject<{ data: z.ZodString; format: z.ZodEnum<{ wav: "wav"; mp3: "mp3"; }>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file: z.ZodObject<{ file_id: z.ZodOptional; filename: z.ZodOptional; file_data: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refusal">; refusal: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>>; tool_call_id: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"function">; name: z.ZodString; content: z.ZodNullable; }, z.core.$strip>], "role">>; tools: z.ZodOptional; function: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; parameters: z.ZodOptional>; strict: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>>>; tool_choice: z.ZodOptional, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{ type: z.ZodLiteral<"function">; function: z.ZodObject<{ name: z.ZodString; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool">; name: z.ZodString; }, z.core.$strip>]>>; max_tokens: z.ZodOptional; max_completion_tokens: z.ZodOptional; temperature: z.ZodOptional; top_p: z.ZodOptional; stop: z.ZodOptional]>>; stream: z.ZodOptional; stream_options: z.ZodOptional; }, z.core.$strip>>; response_format: z.ZodOptional; seed: z.ZodOptional; presence_penalty: z.ZodOptional; frequency_penalty: z.ZodOptional; logit_bias: z.ZodOptional>; user: z.ZodOptional; reasoning_effort: z.ZodOptional>; parallel_tool_calls: z.ZodOptional; service_tier: z.ZodOptional>; metadata: z.ZodOptional>; logprobs: z.ZodOptional; top_logprobs: z.ZodOptional; prediction: z.ZodOptional; modalities: z.ZodOptional; audio: z.ZodOptional; store: z.ZodOptional; prompt_cache_key: z.ZodOptional; safety_identifier: z.ZodOptional; n: z.ZodOptional; web_search_options: z.ZodOptional; }, z.core.$strip>; /** * Public types are sourced from the OpenAI SDK so the gateway stays in * lock-step with the canonical API surface; the schemas above are runtime * validators for the subset we actually accept. */ export type OpenAIChatRequest = ChatCompletionCreateParams; export type OpenAIChatMessage = ChatCompletionMessageParam; export type OpenAIChatToolCall = ChatCompletionMessageToolCall; export type OpenAIChatTool = ChatCompletionTool; export type OpenAIChatToolChoice = ChatCompletionToolChoiceOption; export type OpenAIChatContentPart = ChatCompletionContentPart;