import {z} from 'zod' export type AIGatewayEntityIdentifier = string; export type PublicLabels = {[key: string]: string}; export type ManagedBy = {[key: string]: string}; export type AIGatewayDatastoreName = string; export type AIGatewayDatastoreRef = {name: AIGatewayDatastoreName}; export type AIGatewayTokenVaultDatastores = Array; export type AIGatewayTokenVaultCredentialPlacement = {location?: ('header' | 'body' | 'query') | undefined, name?: string | undefined, prefix?: string | undefined}; export type AIGatewayTokenVaultCredential = {inbound?: AIGatewayTokenVaultCredentialPlacement | undefined, outbound?: AIGatewayTokenVaultCredentialPlacement | undefined}; export type AIGatewayRedisAWSAuthentication = {type: 'aws', access_key_id?: string | undefined, assume_role_arn?: string | undefined, cache_name?: string | undefined, is_serverless?: boolean | undefined, region?: string | undefined, role_session_name?: string | undefined, secret_access_key?: string | undefined}; export type AIGatewayRedisAzureAuthentication = {type: 'azure', client_id?: string | undefined, client_secret?: string | undefined, tenant_id?: string | undefined}; export type AIGatewayRedisGCPAuthentication = {type: 'gcp', service_account_json?: string | undefined}; export type AIGatewayRedisCloudConfiguration = {cloud_authentication?: (AIGatewayRedisAWSAuthentication | AIGatewayRedisAzureAuthentication | AIGatewayRedisGCPAuthentication) | undefined, cluster?: ({max_redirections?: number | undefined, nodes?: (Array<{ip?: string | undefined, port?: number | undefined}>) | undefined}) | undefined, connect_timeout?: number | undefined, connection_is_proxied?: boolean | undefined, database?: number | undefined, host?: string | undefined, keepalive?: ({backlog?: number | undefined, pool_size?: number | undefined}) | undefined, password?: string | undefined, port?: (number | string) | undefined, read_timeout?: number | undefined, send_timeout?: number | undefined, sentinel?: ({master?: string | undefined, nodes?: (Array<{host?: string | undefined, port?: number | undefined}>) | undefined, password?: string | undefined, role?: ('any' | 'master' | 'slave') | undefined, username?: string | undefined}) | undefined, server_name?: string | undefined, ssl?: boolean | undefined, ssl_verify?: boolean | undefined, username?: string | undefined}; export type TokenVaultDatastoreKey = {version: string, key?: string | undefined}; export type TokenVaultDatastoreConfig = {directory: string, current_version: string, keys: Array}; export type AIGatewayTokenVault = {provider: string, subject_token_type?: ('access_token' | 'api_key') | undefined, credential?: AIGatewayTokenVaultCredential | undefined, cache?: ({redis?: AIGatewayRedisCloudConfiguration | undefined}) | undefined, storage?: TokenVaultDatastoreConfig | undefined}; export type AIGatewayModelProviderConfigAuthBasic = {type: 'basic', headers?: (Array<{name: string, value?: string | undefined}>) | undefined, params?: (Array<{name: string, value?: string | undefined, location: 'body' | 'query'}>) | undefined}; export type AIGatewayModelProviderAnthropic = {type: 'anthropic', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderConfigAuthAzure = {type: 'azure', client_id?: string | undefined, client_secret?: string | undefined, tenant_id?: string | undefined, use_managed_identity?: boolean | undefined}; export type AIGatewayModelProviderAzure = {type: 'azure', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic | AIGatewayModelProviderConfigAuthAzure, service?: ('azure-openai' | 'azure-foundry') | undefined, instance?: string | undefined, foundry?: ({resource: string, domain?: string | undefined}) | undefined}}; export type AIGatewayModelProviderBaseten = {type: 'baseten', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderConfigAuthAWS = {type: 'aws', access_key_id?: string | undefined, secret_access_key?: string | undefined, session_token?: string | undefined, assume_role_arn?: string | undefined, role_session_name?: string | undefined, sts_endpoint_url?: string | undefined, batch_role_arn?: string | undefined}; export type AIGatewayModelProviderBedrock = {type: 'bedrock', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic | AIGatewayModelProviderConfigAuthAWS}}; export type AIGatewayModelProviderCerebras = {type: 'cerebras', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderCohere = {type: 'cohere', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderDashscope = {type: 'dashscope', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderDatabricks = {type: 'databricks', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderDeepseek = {type: 'deepseek', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayUpstreamAuthAWS = {type: 'aws', access_key_id?: string | undefined, secret_access_key?: string | undefined, session_token?: string | undefined, region?: string | undefined, assume_role_arn?: string | undefined, role_session_name?: string | undefined, sts_endpoint_url?: string | undefined}; export type AuthGCPWorkloadIdentityFederation = {source: 'aws_iam', auth_json?: string | undefined, aws?: AIGatewayUpstreamAuthAWS | undefined}; export type AIGatewayModelProviderConfigAuthGCP = {type: 'gcp', service_account_json?: string | undefined, metadata_url?: string | undefined, oauth_token_url?: string | undefined, use_gcp_service_account?: boolean | undefined, workload_identity_federation?: AuthGCPWorkloadIdentityFederation | undefined}; export type AIGatewayModelProviderGemini = {type: 'gemini', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic | AIGatewayModelProviderConfigAuthGCP}}; export type AIGatewayModelProviderHuggingface = {type: 'huggingface', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderKimi = {type: 'kimi', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderLlama2 = {type: 'llama2', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderMistral = {type: 'mistral', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderOllama = {type: 'ollama', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderOpenai = {type: 'openai', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderVercel = {type: 'vercel', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderVllm = {type: 'vllm', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderXai = {type: 'xai', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type AIGatewayModelProviderConfigAuthSagemaker = {type: 'sagemaker', aws?: ({access_key_id?: string | undefined, secret_access_key?: string | undefined, session_token?: string | undefined}) | undefined}; export type AIGatewayModelProviderSagemaker = {type: 'sagemaker', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic | AIGatewayModelProviderConfigAuthSagemaker}}; export type AIGatewayModelProviderTypesafe = {type: 'typesafe', display_name: string, name: AIGatewayEntityIdentifier, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined, datastores?: AIGatewayTokenVaultDatastores | undefined, token_vault?: AIGatewayTokenVault | undefined, config: {auth: AIGatewayModelProviderConfigAuthBasic}}; export type CreateAIGatewayModelProviderRequest = AIGatewayModelProviderAnthropic | AIGatewayModelProviderAzure | AIGatewayModelProviderBaseten | AIGatewayModelProviderBedrock | AIGatewayModelProviderCerebras | AIGatewayModelProviderCohere | AIGatewayModelProviderDashscope | AIGatewayModelProviderDatabricks | AIGatewayModelProviderDeepseek | AIGatewayModelProviderGemini | AIGatewayModelProviderHuggingface | AIGatewayModelProviderKimi | AIGatewayModelProviderLlama2 | AIGatewayModelProviderMistral | AIGatewayModelProviderOllama | AIGatewayModelProviderOpenai | AIGatewayModelProviderVercel | AIGatewayModelProviderVllm | AIGatewayModelProviderXai | AIGatewayModelProviderSagemaker | AIGatewayModelProviderTypesafe; export type CreateApiV1AiGatewaysGatewayIdModelProvidersArgs = {body: CreateAIGatewayModelProviderRequest}; export type CreateApiV1AiGatewaysGatewayIdModelProvidersOptions = {baseUrl?: string | undefined, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const uUID = z.string(); export const createdAt = z.string(); export const updatedAt = z.string(); export const aIGatewayEntityIdentifier = z.string().min(1).max(256); export const publicLabels = z.record(z.string(), z.string().min(1).max(63)); export const managedBy = z.record(z.string(), z.string().min(1).max(63)); export const aIGatewayDatastoreName = z.string().min(2).max(255); export const aIGatewayDatastoreRef = z.object({name: aIGatewayDatastoreName}); export const aIGatewayTokenVaultDatastores = z.array(aIGatewayDatastoreRef); export const aIGatewayTokenVaultCredentialPlacement = z.object({location: z.enum(["header", "body", "query"]).optional(), name: z.string().optional(), prefix: z.string().optional()}); export const aIGatewayTokenVaultCredential = z.object({inbound: aIGatewayTokenVaultCredentialPlacement.optional(), outbound: aIGatewayTokenVaultCredentialPlacement.optional()}); export const aIGatewayRedisAWSAuthentication = z.object({type: z.literal("aws"), access_key_id: z.string().optional(), assume_role_arn: z.string().optional(), cache_name: z.string().optional(), is_serverless: z.boolean().optional(), region: z.string().optional(), role_session_name: z.string().optional(), secret_access_key: z.string().optional()}); export const aIGatewayRedisAzureAuthentication = z.object({type: z.literal("azure"), client_id: z.string().optional(), client_secret: z.string().optional(), tenant_id: z.string().optional()}); export const aIGatewayRedisGCPAuthentication = z.object({type: z.literal("gcp"), service_account_json: z.string().optional()}); export const aIGatewayRedisCloudConfiguration = z.object({cloud_authentication: z.discriminatedUnion("type", [aIGatewayRedisAWSAuthentication, aIGatewayRedisAzureAuthentication, aIGatewayRedisGCPAuthentication]).optional(), cluster: z.object({max_redirections: z.number().int().gte(0).lte(2147483646).optional(), nodes: z.array(z.object({ip: z.string().optional(), port: z.number().int().gte(0).lte(65535).optional()})).optional()}).optional(), connect_timeout: z.number().int().gte(0).lte(2147483646).optional(), connection_is_proxied: z.boolean().optional(), database: z.number().int().gte(0).lte(2147483646).optional(), host: z.string().optional(), keepalive: z.object({backlog: z.number().int().gte(0).lte(2147483646).optional(), pool_size: z.number().int().gte(1).lte(2147483646).optional()}).optional(), password: z.string().optional(), port: z.union([z.number().int().gte(0).lte(65535), z.string()]).optional(), read_timeout: z.number().int().gte(0).lte(2147483646).optional(), send_timeout: z.number().int().gte(0).lte(2147483646).optional(), sentinel: z.object({master: z.string().optional(), nodes: z.array(z.object({host: z.string().optional(), port: z.number().int().gte(0).lte(65535).optional()})).optional(), password: z.string().optional(), role: z.enum(["any", "master", "slave"]).optional(), username: z.string().optional()}).optional(), server_name: z.string().optional(), ssl: z.boolean().optional(), ssl_verify: z.boolean().optional(), username: z.string().optional()}); export const tokenVaultDatastoreKey = z.object({version: z.string(), key: z.string().optional()}); export const tokenVaultDatastoreConfig = z.object({directory: z.string(), current_version: z.string(), keys: z.array(tokenVaultDatastoreKey)}); export const aIGatewayTokenVault = z.object({provider: z.string(), subject_token_type: z.enum(["access_token", "api_key"]).optional(), credential: aIGatewayTokenVaultCredential.optional(), cache: z.object({redis: aIGatewayRedisCloudConfiguration.optional()}).optional(), storage: tokenVaultDatastoreConfig.optional()}); export const aIGatewayModelProviderConfigAuthBasic = z.object({type: z.literal("basic"), headers: z.array(z.object({name: z.string(), value: z.string().optional()})).optional(), params: z.array(z.object({name: z.string(), value: z.string().optional(), location: z.enum(["body", "query"])})).optional()}); export const aIGatewayModelProviderConfigAuthAzure = z.object({type: z.literal("azure"), client_id: z.string().optional(), client_secret: z.string().optional(), tenant_id: z.string().optional(), use_managed_identity: z.boolean().optional()}); export const aIGatewayModelProviderConfigAuthAWS = z.object({type: z.literal("aws"), access_key_id: z.string().optional(), secret_access_key: z.string().optional(), session_token: z.string().optional(), assume_role_arn: z.string().optional(), role_session_name: z.string().optional(), sts_endpoint_url: z.string().optional(), batch_role_arn: z.string().optional()}); export const aIGatewayUpstreamAuthAWS = z.object({type: z.literal("aws"), access_key_id: z.string().optional(), secret_access_key: z.string().optional(), session_token: z.string().optional(), region: z.string().optional(), assume_role_arn: z.string().optional(), role_session_name: z.string().optional(), sts_endpoint_url: z.string().optional()}); export const authGCPWorkloadIdentityFederation = z.object({source: z.literal("aws_iam"), auth_json: z.string().optional(), aws: aIGatewayUpstreamAuthAWS.optional()}); export const aIGatewayModelProviderConfigAuthGCP = z.object({type: z.literal("gcp"), service_account_json: z.string().optional(), metadata_url: z.string().optional(), oauth_token_url: z.string().optional(), use_gcp_service_account: z.boolean().optional(), workload_identity_federation: authGCPWorkloadIdentityFederation.optional()}); export const aIGatewayModelProviderConfigAuthSagemaker = z.object({type: z.literal("sagemaker"), aws: z.object({access_key_id: z.string().optional(), secret_access_key: z.string().optional(), session_token: z.string().optional()}).optional()}); export const aIGatewayModelProvider = z.discriminatedUnion("type", [z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("anthropic"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("azure"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: z.discriminatedUnion("type", [aIGatewayModelProviderConfigAuthBasic, aIGatewayModelProviderConfigAuthAzure]), service: z.enum(["azure-openai", "azure-foundry"]).optional(), instance: z.string().optional(), foundry: z.object({resource: z.string(), domain: z.string().optional()}).optional()})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("baseten"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("bedrock"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: z.discriminatedUnion("type", [aIGatewayModelProviderConfigAuthBasic, aIGatewayModelProviderConfigAuthAWS])})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("cerebras"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("cohere"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("dashscope"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("databricks"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("deepseek"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("gemini"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: z.discriminatedUnion("type", [aIGatewayModelProviderConfigAuthBasic, aIGatewayModelProviderConfigAuthGCP])})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("huggingface"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("kimi"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("llama2"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("mistral"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("ollama"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("openai"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("vercel"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("vllm"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("xai"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("sagemaker"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: z.discriminatedUnion("type", [aIGatewayModelProviderConfigAuthBasic, aIGatewayModelProviderConfigAuthSagemaker])})}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("typesafe"), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, labels: publicLabels.optional(), managed_by: managedBy.optional(), datastores: aIGatewayTokenVaultDatastores.optional(), token_vault: aIGatewayTokenVault.optional(), config: z.object({auth: aIGatewayModelProviderConfigAuthBasic})})]); 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 }; /** * Create an AI Gateway Model Provider * * POST /v1/ai-gateways/{gatewayId}/model-providers * * Also accepts auth: systemAccountAccessToken, konnectAccessToken, serviceAccessToken */ export const createApiV1AiGatewaysGatewayIdModelProviders = async (args: CreateApiV1AiGatewaysGatewayIdModelProvidersArgs, options?: CreateApiV1AiGatewaysGatewayIdModelProvidersOptions) => { const {baseUrl = "https://global.api.konghq.com", fetch: fetchFn = fetch, personalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (personalAccessToken !== undefined) headers.set('authorization', `Bearer ${personalAccessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/ai-gateways/${encodeURIComponent(String(args.gatewayId))}/model-providers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(aIGatewayModelProvider, await res.json()) };