From 200ea567a7bf8075e4d5a12810fefa80f9861b51 Mon Sep 17 00:00:00 2001 From: dal Date: Mon, 29 Sep 2025 09:46:31 -0600 Subject: [PATCH] add in type for anthropic gateway --- packages/ai/src/llm/providers/gateway.ts | 41 ++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/packages/ai/src/llm/providers/gateway.ts b/packages/ai/src/llm/providers/gateway.ts index 50df61eaa..c5438b7c8 100644 --- a/packages/ai/src/llm/providers/gateway.ts +++ b/packages/ai/src/llm/providers/gateway.ts @@ -2,7 +2,44 @@ import { createGateway } from '@ai-sdk/gateway'; import { wrapLanguageModel } from 'ai'; import { BraintrustMiddleware } from 'braintrust'; -export const DEFAULT_ANTHROPIC_OPTIONS = { +// Provider-specific option types +export type GatewayProviderOrder = string[]; + +export type AnthropicOptions = { + cacheControl?: { type: 'ephemeral' }; +}; + +export type BedrockOptions = { + cachePoint?: { type: 'default' }; + additionalModelRequestFields?: { + anthropic_beta?: string[]; + }; +}; + +export type OpenAIOptions = { + // parallelToolCalls?: boolean; + reasoningEffort?: 'low' | 'medium' | 'high' | 'minimal'; + verbosity?: 'low' | 'medium' | 'high'; +}; + +// Main provider options types +export type AnthropicProviderOptions = { + gateway: { + order: GatewayProviderOrder; + }; + anthropic: AnthropicOptions; + bedrock: BedrockOptions; +}; + +export type OpenAIProviderOptions = { + gateway: { + order: GatewayProviderOrder; + }; + openai: OpenAIOptions; +}; + +// Default options with proper typing +export const DEFAULT_ANTHROPIC_OPTIONS: AnthropicProviderOptions = { gateway: { order: ['bedrock', 'anthropic', 'vertex'], }, @@ -17,7 +54,7 @@ export const DEFAULT_ANTHROPIC_OPTIONS = { }, }; -export const DEFAULT_OPENAI_OPTIONS = { +export const DEFAULT_OPENAI_OPTIONS: OpenAIProviderOptions = { gateway: { order: ['openai'], },