/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 7d8c6b68d130 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { JsonSchema, JsonSchema$Outbound, JsonSchema$outboundSchema, } from "./jsonschema.js"; import { ResponseFormats, ResponseFormats$outboundSchema, } from "./responseformats.js"; /** * Specify the format that the model must output. By default it will use `{ "type": "text" }`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ "type": "json_schema" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide. */ export type ResponseFormat = { type?: ResponseFormats | undefined; jsonSchema?: JsonSchema | null | undefined; }; /** @internal */ export type ResponseFormat$Outbound = { type?: string | undefined; json_schema?: JsonSchema$Outbound | null | undefined; }; /** @internal */ export const ResponseFormat$outboundSchema: z.ZodType< ResponseFormat$Outbound, ResponseFormat > = z.object({ type: ResponseFormats$outboundSchema.optional(), jsonSchema: z.nullable(JsonSchema$outboundSchema).optional(), }).transform((v) => { return remap$(v, { jsonSchema: "json_schema", }); }); export function responseFormatToJSON(responseFormat: ResponseFormat): string { return JSON.stringify(ResponseFormat$outboundSchema.parse(responseFormat)); }