import {z} from 'zod' export type GetApiV1AccountsAccountIdDeploymentShapesArgs = {pageSize?: number | undefined, pageToken?: string | undefined, filter?: string | undefined, orderBy?: string | undefined, readMask?: string | undefined, targetModel?: string | undefined, account_id: string}; export type GetApiV1AccountsAccountIdDeploymentShapesOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const gatewayAcceleratorType = z.enum(["ACCELERATOR_TYPE_UNSPECIFIED", "NVIDIA_A100_80GB", "NVIDIA_H100_80GB", "AMD_MI300X_192GB", "NVIDIA_A10G_24GB", "NVIDIA_A100_40GB", "NVIDIA_L4_24GB", "NVIDIA_H200_141GB", "NVIDIA_B200_180GB", "AMD_MI325X_256GB", "AMD_MI350X_288GB", "NVIDIA_B300_288GB", "NVIDIA_GB200", "NVIDIA_GB300"]); export const deploymentPrecision = z.enum(["PRECISION_UNSPECIFIED", "FP16", "FP8", "FP8_MM", "FP8_AR", "FP8_MM_KV_ATTN", "FP8_KV", "FP8_MM_V2", "FP8_V2", "FP8_MM_KV_ATTN_V2", "NF4", "FP4", "BF16", "FP4_BLOCKSCALED_MM", "FP4_MX_MOE"]); export const deploymentShapePresetType = z.enum(["PRESET_TYPE_UNSPECIFIED", "MINIMAL", "FAST", "THROUGHPUT", "FULL_PRECISION", "AGENTIC_CODING", "CHAT", "SUMMARIZATION", "MULTI_LORA"]); export const gatewayDeploymentShape = z.object({name: z.string().optional(), displayName: z.string().optional(), description: z.string().optional(), createTime: z.string().optional(), updateTime: z.string().optional(), baseModel: z.string(), modelType: z.string().optional(), parameterCount: z.string().optional(), acceleratorCount: z.number().int().optional(), acceleratorType: gatewayAcceleratorType.optional(), precision: deploymentPrecision.optional(), disableDeploymentSizeValidation: z.boolean().optional(), enableAddons: z.boolean().optional(), draftTokenCount: z.number().int().optional(), draftModel: z.string().optional(), ngramSpeculationLength: z.number().int().optional(), disableSpeculativeDecoding: z.boolean().optional(), enableSessionAffinity: z.boolean().optional(), numLoraDeviceCached: z.number().int().optional(), maxContextLength: z.number().int().optional(), presetType: deploymentShapePresetType.optional()}); export const gatewayListDeploymentShapesResponse = z.object({deploymentShapes: z.array(gatewayDeploymentShape).optional(), nextPageToken: z.string().optional(), totalSize: z.number().int().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List Deployment Shapes * * GET /v1/accounts/{account_id}/deploymentShapes */ export const getApiV1AccountsAccountIdDeploymentShapes = async (args: GetApiV1AccountsAccountIdDeploymentShapesArgs, options: GetApiV1AccountsAccountIdDeploymentShapesOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (args.filter != null) query.append("filter", String(args.filter)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.readMask != null) query.append("readMask", String(args.readMask)) if (args.targetModel != null) query.append("targetModel", String(args.targetModel)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.account_id))}/deploymentShapes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(gatewayListDeploymentShapesResponse, await res.json()) };