/* * 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 GetModelRequest = { modelId: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export const ModelType = { Llm: "llm", Embeddings: "embeddings", Images: "images", SpeechToText: "speech_to_text", TextToSpeech: "text_to_speech", } as const; export type ModelType = ClosedEnum; /** * Curated public sampling capabilities for this model. */ export type Capabilities = { /** * 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; }; /** * OK */ export type GetModelResponseBody = { id: string; object: "model"; created: number; ownedBy: string; modelType: ModelType; /** * Curated public sampling capabilities for this model. */ capabilities: Capabilities; }; /** @internal */ export const GetModelRequest$inboundSchema: z.ZodType< GetModelRequest, z.ZodTypeDef, unknown > = z.object({ model_id: z.string(), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "model_id": "modelId", "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type GetModelRequest$Outbound = { model_id: string; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const GetModelRequest$outboundSchema: z.ZodType< GetModelRequest$Outbound, z.ZodTypeDef, GetModelRequest > = z.object({ modelId: z.string(), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { modelId: "model_id", xOnBehalfOf: "X-On-Behalf-Of", }); }); export function getModelRequestToJSON( getModelRequest: GetModelRequest, ): string { return JSON.stringify(GetModelRequest$outboundSchema.parse(getModelRequest)); } export function getModelRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetModelRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetModelRequest' from JSON`, ); } /** @internal */ export const ModelType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ModelType); /** @internal */ export const ModelType$outboundSchema: z.ZodNativeEnum = ModelType$inboundSchema; /** @internal */ export const Capabilities$inboundSchema: z.ZodType< Capabilities, 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 Capabilities$Outbound = { supports_temperature: boolean; supports_top_p: boolean; }; /** @internal */ export const Capabilities$outboundSchema: z.ZodType< Capabilities$Outbound, z.ZodTypeDef, Capabilities > = z.object({ supportsTemperature: z.boolean(), supportsTopP: z.boolean(), }).transform((v) => { return remap$(v, { supportsTemperature: "supports_temperature", supportsTopP: "supports_top_p", }); }); export function capabilitiesToJSON(capabilities: Capabilities): string { return JSON.stringify(Capabilities$outboundSchema.parse(capabilities)); } export function capabilitiesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Capabilities$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Capabilities' from JSON`, ); } /** @internal */ export const GetModelResponseBody$inboundSchema: z.ZodType< GetModelResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("model"), created: z.number().int(), owned_by: z.string(), model_type: ModelType$inboundSchema, capabilities: z.lazy(() => Capabilities$inboundSchema), }).transform((v) => { return remap$(v, { "owned_by": "ownedBy", "model_type": "modelType", }); }); /** @internal */ export type GetModelResponseBody$Outbound = { id: string; object: "model"; created: number; owned_by: string; model_type: string; capabilities: Capabilities$Outbound; }; /** @internal */ export const GetModelResponseBody$outboundSchema: z.ZodType< GetModelResponseBody$Outbound, z.ZodTypeDef, GetModelResponseBody > = z.object({ id: z.string(), object: z.literal("model"), created: z.number().int(), ownedBy: z.string(), modelType: ModelType$outboundSchema, capabilities: z.lazy(() => Capabilities$outboundSchema), }).transform((v) => { return remap$(v, { ownedBy: "owned_by", modelType: "model_type", }); }); export function getModelResponseBodyToJSON( getModelResponseBody: GetModelResponseBody, ): string { return JSON.stringify( GetModelResponseBody$outboundSchema.parse(getModelResponseBody), ); } export function getModelResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetModelResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetModelResponseBody' from JSON`, ); }