/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListModelsRequest = { /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export const ListModelsModelType = { Llm: "llm", Embeddings: "embeddings", Images: "images", SpeechToText: "speech_to_text", TextToSpeech: "text_to_speech", } as const; export type ListModelsModelType = ClosedEnum; /** * Curated public sampling capabilities for this model. */ export type ListModelsCapabilities = { /** * Whether an LLM accepts the temperature parameter on chat-shaped generation routes; false for non-LLM models. */ supportsTemperature: boolean; /** * Whether an LLM accepts the top_p parameter on chat-shaped generation routes; false for non-LLM models. */ supportsTopP: boolean; }; export type ListModelsData = { id: string; object: "model"; created: number; ownedBy: string; modelType: ListModelsModelType; /** * Curated public sampling capabilities for this model. */ capabilities: ListModelsCapabilities; }; /** * OK */ export type ListModelsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const ListModelsRequest$inboundSchema: z.ZodType< ListModelsRequest, z.ZodTypeDef, unknown > = z.object({ "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ListModelsRequest$Outbound = { "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ListModelsRequest$outboundSchema: z.ZodType< ListModelsRequest$Outbound, z.ZodTypeDef, ListModelsRequest > = z.object({ xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", }); }); export function listModelsRequestToJSON( listModelsRequest: ListModelsRequest, ): string { return JSON.stringify( ListModelsRequest$outboundSchema.parse(listModelsRequest), ); } export function listModelsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListModelsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListModelsRequest' from JSON`, ); } /** @internal */ export const ListModelsModelType$inboundSchema: z.ZodNativeEnum< typeof ListModelsModelType > = z.nativeEnum(ListModelsModelType); /** @internal */ export const ListModelsModelType$outboundSchema: z.ZodNativeEnum< typeof ListModelsModelType > = ListModelsModelType$inboundSchema; /** @internal */ export const ListModelsCapabilities$inboundSchema: z.ZodType< ListModelsCapabilities, z.ZodTypeDef, unknown > = z.object({ supports_temperature: z.boolean(), supports_top_p: z.boolean(), }).transform((v) => { return remap$(v, { "supports_temperature": "supportsTemperature", "supports_top_p": "supportsTopP", }); }); /** @internal */ export type ListModelsCapabilities$Outbound = { supports_temperature: boolean; supports_top_p: boolean; }; /** @internal */ export const ListModelsCapabilities$outboundSchema: z.ZodType< ListModelsCapabilities$Outbound, z.ZodTypeDef, ListModelsCapabilities > = z.object({ supportsTemperature: z.boolean(), supportsTopP: z.boolean(), }).transform((v) => { return remap$(v, { supportsTemperature: "supports_temperature", supportsTopP: "supports_top_p", }); }); export function listModelsCapabilitiesToJSON( listModelsCapabilities: ListModelsCapabilities, ): string { return JSON.stringify( ListModelsCapabilities$outboundSchema.parse(listModelsCapabilities), ); } export function listModelsCapabilitiesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListModelsCapabilities$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListModelsCapabilities' from JSON`, ); } /** @internal */ export const ListModelsData$inboundSchema: z.ZodType< ListModelsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("model"), created: z.number().int(), owned_by: z.string(), model_type: ListModelsModelType$inboundSchema, capabilities: z.lazy(() => ListModelsCapabilities$inboundSchema), }).transform((v) => { return remap$(v, { "owned_by": "ownedBy", "model_type": "modelType", }); }); /** @internal */ export type ListModelsData$Outbound = { id: string; object: "model"; created: number; owned_by: string; model_type: string; capabilities: ListModelsCapabilities$Outbound; }; /** @internal */ export const ListModelsData$outboundSchema: z.ZodType< ListModelsData$Outbound, z.ZodTypeDef, ListModelsData > = z.object({ id: z.string(), object: z.literal("model"), created: z.number().int(), ownedBy: z.string(), modelType: ListModelsModelType$outboundSchema, capabilities: z.lazy(() => ListModelsCapabilities$outboundSchema), }).transform((v) => { return remap$(v, { ownedBy: "owned_by", modelType: "model_type", }); }); export function listModelsDataToJSON(listModelsData: ListModelsData): string { return JSON.stringify(ListModelsData$outboundSchema.parse(listModelsData)); } export function listModelsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListModelsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListModelsData' from JSON`, ); } /** @internal */ export const ListModelsResponseBody$inboundSchema: z.ZodType< ListModelsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListModelsData$inboundSchema)), }); /** @internal */ export type ListModelsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const ListModelsResponseBody$outboundSchema: z.ZodType< ListModelsResponseBody$Outbound, z.ZodTypeDef, ListModelsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListModelsData$outboundSchema)), }); export function listModelsResponseBodyToJSON( listModelsResponseBody: ListModelsResponseBody, ): string { return JSON.stringify( ListModelsResponseBody$outboundSchema.parse(listModelsResponseBody), ); } export function listModelsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListModelsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListModelsResponseBody' from JSON`, ); }