import {z} from 'zod' export type GetApiV1AccountsAccountIdDeploymentShapesDeploymentShapeIdArgs = {readMask?: string | undefined, skipShapeValidation?: boolean | undefined, account_id: string, deployment_shape_id: string}; export type GetApiV1AccountsAccountIdDeploymentShapesDeploymentShapeIdOptions = {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 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 }; /** * Get Deployment Shape * * GET /v1/accounts/{account_id}/deploymentShapes/{deployment_shape_id} */ export const getApiV1AccountsAccountIdDeploymentShapesDeploymentShapeId = async (args: GetApiV1AccountsAccountIdDeploymentShapesDeploymentShapeIdArgs, options: GetApiV1AccountsAccountIdDeploymentShapesDeploymentShapeIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.readMask != null) query.append("readMask", String(args.readMask)) if (args.skipShapeValidation != null) query.append("skipShapeValidation", String(args.skipShapeValidation)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.account_id))}/deploymentShapes/${encodeURIComponent(String(args.deployment_shape_id))}${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(gatewayDeploymentShape, await res.json()) };