import type { infer as zodInfer, ZodType } from 'zod'; /** * Structured Outputs configuration options, including a JSON Schema. */ export interface JSONSchema { /** * The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores * and dashes, with a maximum length of 64. */ name: string; /** * A description of what the response format is for, used by the model to determine * how to respond in the format. */ description?: string; /** * The schema for the response format, described as a JSON Schema object. Learn how * to build JSON schemas [here](https://json-schema.org/). */ schema?: Record; /** * Whether to enable strict schema adherence when generating the output. If set to * true, the model will always follow the exact schema defined in the `schema` * field. Only a subset of JSON Schema is supported when `strict` is `true`. To * learn more, read the * [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). */ strict?: boolean | null; } /** * JSON Schema response format. Used to generate structured JSON responses. Learn * more about * [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). */ export interface ResponseFormatJSONSchema { /** * Structured Outputs configuration options, including a JSON Schema. */ json_schema: JSONSchema; /** * The type of response format being defined. Always `json_schema`. */ type: 'json_schema'; } export type AutoParseableResponseFormat = ResponseFormatJSONSchema & { __output: ParsedT; $brand: 'auto-parseable-response-format'; $parseRaw(content: string): ParsedT; }; export declare function makeParseableResponseFormat(response_format: ResponseFormatJSONSchema, parser: (content: string) => ParsedT): AutoParseableResponseFormat; /** * Creates a chat completion `JSONSchema` response format object from * the given Zod schema. * * If this is passed to the `.parse()`, `.stream()` or `.runTools()` * chat completion methods then the response message will contain a * `.parsed` property that is the result of parsing the content with * the given Zod object. * * ```ts * const completion = await client.beta.chat.completions.parse({ * model: 'gpt-4o-2024-08-06', * messages: [ * { role: 'system', content: 'You are a helpful math tutor.' }, * { role: 'user', content: 'solve 8x + 31 = 2' }, * ], * response_format: zodResponseFormat( * z.object({ * steps: z.array(z.object({ * explanation: z.string(), * answer: z.string(), * })), * final_answer: z.string(), * }), * 'math_answer', * ), * }); * const message = completion.choices[0]?.message; * if (message?.parsed) { * console.log(message.parsed); * console.log(message.parsed.final_answer); * } * ``` * * This can be passed directly to the `.create()` method but will not * result in any automatic parsing, you'll have to parse the response yourself. */ export declare function zodResponseFormat(zodObject: ZodInput, name: string, props?: Omit): AutoParseableResponseFormat>;