UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

457 lines (427 loc) 12.4 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ export const AiGatewayVirtualModelConfigInferenceRegionScope = { Global: "global", Specific: "specific", Zone: "zone", } as const; /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ export type AiGatewayVirtualModelConfigInferenceRegionScope = ClosedEnum< typeof AiGatewayVirtualModelConfigInferenceRegionScope >; /** * Per-provider region overrides keyed by provider slug. */ export type Providers = { /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ scope?: AiGatewayVirtualModelConfigInferenceRegionScope | undefined; /** * Geo zone (e.g. "us", "eu"). */ geoRegion?: string | undefined; /** * Provider-specific region identifier. */ providerRegion?: string | undefined; }; /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ export const AiGatewayVirtualModelConfigScope = { Global: "global", Specific: "specific", Zone: "zone", } as const; /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ export type AiGatewayVirtualModelConfigScope = ClosedEnum< typeof AiGatewayVirtualModelConfigScope >; /** * Region pinned on the VMC for system-credential routing (alias/router only). */ export type InferenceRegion = { /** * Per-provider region overrides keyed by provider slug. */ providers?: { [k: string]: Providers | null } | undefined; /** * Pin scope: `specific` (one provider region), `zone` (geo zone), or `global`. */ scope?: AiGatewayVirtualModelConfigScope | undefined; /** * Geo zone (e.g. "us", "eu"). */ geoRegion?: string | undefined; /** * Provider-specific region identifier. */ providerRegion?: string | undefined; }; /** * For kind=router: how to order candidates. */ export const Selector = { Cost: "cost", Priority: "priority", Tps: "tps", Ttft: "ttft", } as const; /** * For kind=router: how to order candidates. */ export type Selector = ClosedEnum<typeof Selector>; /** * Rank eligible providers by an attribute. */ export const Sort = { Cost: "cost", Latency: "latency", Price: "price", Throughput: "throughput", Tps: "tps", Ttft: "ttft", } as const; /** * Rank eligible providers by an attribute. */ export type Sort = ClosedEnum<typeof Sort>; /** * Limit providers to those with these features. */ export const Has = { ImplicitCaching: "implicit-caching", Vision: "vision", } as const; /** * Limit providers to those with these features. */ export type Has = ClosedEnum<typeof Has>; /** * Use caching if available. */ export const Caching = { Auto: "auto", } as const; /** * Use caching if available. */ export type Caching = ClosedEnum<typeof Caching>; /** * Service tier for providers that support it. */ export const ServiceTier = { Fast: "fast", Flex: "flex", Priority: "priority", } as const; /** * Service tier for providers that support it. */ export type ServiceTier = ClosedEnum<typeof ServiceTier>; /** * Per-request provider timeouts in ms, keyed by provider slug for BYOK credentials. */ export type ProviderTimeouts = { byok?: { [k: string]: number } | undefined; }; /** * Only use fastest providers with short timeouts. */ export const Speed = { Fast: "fast", } as const; /** * Only use fastest providers with short timeouts. */ export type Speed = ClosedEnum<typeof Speed>; /** * Public response shape for virtual model configs. Used so OpenAPI generation can avoid ElectroDB's recursive EntityItem types. */ export type AiGatewayVirtualModelConfig = { /** * Team (owner) that owns this VMC. */ ownerId: string; /** * Client-facing alias used as the model slug in Gateway calls. */ virtualModelSlug: string; /** * Human-readable name for UI. */ displayName?: string | undefined; /** * Optional description for UI. */ description?: string | undefined; /** * Whether this VMC is soft-deleted. */ deleted: boolean; /** * UI lifecycle status: draft, active, or archived. */ status: string; /** * Visibility in listings: public, internal, or stealth. */ visibility?: string | undefined; /** * User id that last updated this VMC. */ updatedBy?: string | undefined; /** * VMC kind: alias, relay, or router. */ kind: string; /** * For kind=relay: URL the gateway forwards requests to as a transparent proxy. */ baseUrl?: string | undefined; /** * The concrete model-provider instance this VMC resolves to. */ instanceId?: string | undefined; /** * Ordered list of providers to try as fallbacks on failure. */ providerOrder?: Array<string> | undefined; /** * Restrict routing to only these providers. */ providerOnly?: Array<string> | undefined; /** * Arbitrary per-provider AI SDK options, keyed by gateway provider slug. */ providerOptions?: { [k: string]: { [k: string]: any } } | undefined; /** * Region pinned on the VMC for system-credential routing (alias/router only). */ inferenceRegion?: InferenceRegion | undefined; /** * Canonical model slug this VMC maps to (e.g. "creator/model"). Not used by kind=router. */ modelSlug?: string | undefined; /** * For kind=router: ordered candidates, model slugs or router references. Otherwise: fallback models. */ models?: Array<string> | undefined; /** * For kind=router: how to order candidates. */ selector?: Selector | undefined; /** * For kind=router: capability tags a candidate must have. */ requires?: Array<string> | undefined; /** * BYOK credential IDs allowed for this VMC. */ byokCredentialIds?: Array<string> | undefined; /** * Observability tags attached to requests through this VMC. */ observabilityTags?: Array<string> | undefined; /** * Rank eligible providers by an attribute. */ sort?: Sort | undefined; /** * Limit providers to those with these features. */ has?: Array<Has> | undefined; /** * Use caching if available. */ caching?: Caching | undefined; /** * Service tier for providers that support it. */ serviceTier?: ServiceTier | undefined; /** * Per-request provider timeouts in ms, keyed by provider slug for BYOK credentials. */ providerTimeouts?: ProviderTimeouts | undefined; /** * Only use providers with zero data retention. */ zeroDataRetention?: boolean | undefined; /** * Only use HIPAA-compliant providers. */ hipaaCompliant?: boolean | undefined; /** * Only use providers that will not train on your prompts. */ disallowPromptTraining?: boolean | undefined; /** * Only use fastest providers with short timeouts. */ speed?: Speed | undefined; /** * Allow fallback from fast to standard providers on failure. */ allowFallbackFromFast?: boolean | undefined; /** * Creation timestamp (epoch ms). */ createdAt: number; /** * Last update timestamp (epoch ms). */ updatedAt: number; }; /** @internal */ export const AiGatewayVirtualModelConfigInferenceRegionScope$inboundSchema: z.ZodNativeEnum<typeof AiGatewayVirtualModelConfigInferenceRegionScope> = z .nativeEnum(AiGatewayVirtualModelConfigInferenceRegionScope); /** @internal */ export const Providers$inboundSchema: z.ZodType< Providers, z.ZodTypeDef, unknown > = z.object({ scope: types.optional( AiGatewayVirtualModelConfigInferenceRegionScope$inboundSchema, ), geoRegion: types.optional(types.string()), providerRegion: types.optional(types.string()), }); export function providersFromJSON( jsonString: string, ): SafeParseResult<Providers, SDKValidationError> { return safeParse( jsonString, (x) => Providers$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Providers' from JSON`, ); } /** @internal */ export const AiGatewayVirtualModelConfigScope$inboundSchema: z.ZodNativeEnum< typeof AiGatewayVirtualModelConfigScope > = z.nativeEnum(AiGatewayVirtualModelConfigScope); /** @internal */ export const InferenceRegion$inboundSchema: z.ZodType< InferenceRegion, z.ZodTypeDef, unknown > = z.object({ providers: types.optional( z.record(types.nullable(z.lazy(() => Providers$inboundSchema))), ), scope: types.optional(AiGatewayVirtualModelConfigScope$inboundSchema), geoRegion: types.optional(types.string()), providerRegion: types.optional(types.string()), }); export function inferenceRegionFromJSON( jsonString: string, ): SafeParseResult<InferenceRegion, SDKValidationError> { return safeParse( jsonString, (x) => InferenceRegion$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InferenceRegion' from JSON`, ); } /** @internal */ export const Selector$inboundSchema: z.ZodNativeEnum<typeof Selector> = z .nativeEnum(Selector); /** @internal */ export const Sort$inboundSchema: z.ZodNativeEnum<typeof Sort> = z.nativeEnum( Sort, ); /** @internal */ export const Has$inboundSchema: z.ZodNativeEnum<typeof Has> = z.nativeEnum(Has); /** @internal */ export const Caching$inboundSchema: z.ZodNativeEnum<typeof Caching> = z .nativeEnum(Caching); /** @internal */ export const ServiceTier$inboundSchema: z.ZodNativeEnum<typeof ServiceTier> = z .nativeEnum(ServiceTier); /** @internal */ export const ProviderTimeouts$inboundSchema: z.ZodType< ProviderTimeouts, z.ZodTypeDef, unknown > = z.object({ byok: types.optional(z.record(types.number())), }); export function providerTimeoutsFromJSON( jsonString: string, ): SafeParseResult<ProviderTimeouts, SDKValidationError> { return safeParse( jsonString, (x) => ProviderTimeouts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProviderTimeouts' from JSON`, ); } /** @internal */ export const Speed$inboundSchema: z.ZodNativeEnum<typeof Speed> = z.nativeEnum( Speed, ); /** @internal */ export const AiGatewayVirtualModelConfig$inboundSchema: z.ZodType< AiGatewayVirtualModelConfig, z.ZodTypeDef, unknown > = z.object({ ownerId: types.string(), virtualModelSlug: types.string(), displayName: types.optional(types.string()), description: types.optional(types.string()), deleted: types.boolean(), status: types.string(), visibility: types.optional(types.string()), updatedBy: types.optional(types.string()), kind: types.string(), baseUrl: types.optional(types.string()), instanceId: types.optional(types.string()), providerOrder: types.optional(z.array(types.string())), providerOnly: types.optional(z.array(types.string())), providerOptions: types.optional(z.record(z.record(z.any()))), inferenceRegion: types.optional(z.lazy(() => InferenceRegion$inboundSchema)), modelSlug: types.optional(types.string()), models: types.optional(z.array(types.string())), selector: types.optional(Selector$inboundSchema), requires: types.optional(z.array(types.string())), byokCredentialIds: types.optional(z.array(types.string())), observabilityTags: types.optional(z.array(types.string())), sort: types.optional(Sort$inboundSchema), has: types.optional(z.array(Has$inboundSchema)), caching: types.optional(Caching$inboundSchema), serviceTier: types.optional(ServiceTier$inboundSchema), providerTimeouts: types.optional( z.lazy(() => ProviderTimeouts$inboundSchema), ), zeroDataRetention: types.optional(types.boolean()), hipaaCompliant: types.optional(types.boolean()), disallowPromptTraining: types.optional(types.boolean()), speed: types.optional(Speed$inboundSchema), allowFallbackFromFast: types.optional(types.boolean()), createdAt: types.number(), updatedAt: types.number(), }); export function aiGatewayVirtualModelConfigFromJSON( jsonString: string, ): SafeParseResult<AiGatewayVirtualModelConfig, SDKValidationError> { return safeParse( jsonString, (x) => AiGatewayVirtualModelConfig$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AiGatewayVirtualModelConfig' from JSON`, ); }