|
| 1 | +/** |
| 2 | + * OpenAI Provider Metadata |
| 3 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai |
| 4 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/openai/src/openai-chat-language-model.ts#L397-L416 |
| 5 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/openai/src/responses/openai-responses-language-model.ts#L377C7-L384 |
| 6 | + */ |
| 7 | +interface OpenAiProviderMetadata { |
| 8 | + /** |
| 9 | + * The number of predicted output tokens that were accepted. |
| 10 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai#predicted-outputs |
| 11 | + */ |
| 12 | + acceptedPredictionTokens?: number; |
| 13 | + |
| 14 | + /** |
| 15 | + * The number of predicted output tokens that were rejected. |
| 16 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai#predicted-outputs |
| 17 | + */ |
| 18 | + rejectedPredictionTokens?: number; |
| 19 | + |
| 20 | + /** |
| 21 | + * The number of reasoning tokens that the model generated. |
| 22 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai#responses-models |
| 23 | + */ |
| 24 | + reasoningTokens?: number; |
| 25 | + |
| 26 | + /** |
| 27 | + * The number of prompt tokens that were a cache hit. |
| 28 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai#responses-models |
| 29 | + */ |
| 30 | + cachedPromptTokens?: number; |
| 31 | + |
| 32 | + /** |
| 33 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/openai#responses-models |
| 34 | + * |
| 35 | + * The ID of the response. Can be used to continue a conversation. |
| 36 | + */ |
| 37 | + responseId?: string; |
| 38 | +} |
| 39 | + |
| 40 | +/** |
| 41 | + * Anthropic Provider Metadata |
| 42 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/anthropic |
| 43 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/anthropic/src/anthropic-messages-language-model.ts#L346-L352 |
| 44 | + */ |
| 45 | +interface AnthropicProviderMetadata { |
| 46 | + /** |
| 47 | + * The number of tokens that were used to create the cache. |
| 48 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/anthropic#cache-control |
| 49 | + */ |
| 50 | + cacheCreationInputTokens?: number; |
| 51 | + |
| 52 | + /** |
| 53 | + * The number of tokens that were read from the cache. |
| 54 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/anthropic#cache-control |
| 55 | + */ |
| 56 | + cacheReadInputTokens?: number; |
| 57 | +} |
| 58 | + |
| 59 | +/** |
| 60 | + * Amazon Bedrock Provider Metadata |
| 61 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock |
| 62 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/amazon-bedrock/src/bedrock-chat-language-model.ts#L263-L280 |
| 63 | + */ |
| 64 | +interface AmazonBedrockProviderMetadata { |
| 65 | + /** |
| 66 | + * @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseTrace.html |
| 67 | + */ |
| 68 | + trace?: { |
| 69 | + /** |
| 70 | + * The guardrail trace object. |
| 71 | + * @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_GuardrailTraceAssessment.html |
| 72 | + * |
| 73 | + * This was purposely left as unknown as it's a complex object. This can be typed in the future |
| 74 | + * if the SDK decides to support bedrock in a more advanced way. |
| 75 | + */ |
| 76 | + guardrail?: unknown; |
| 77 | + /** |
| 78 | + * The request's prompt router. |
| 79 | + * @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_PromptRouterTrace.html |
| 80 | + */ |
| 81 | + promptRouter?: { |
| 82 | + /** |
| 83 | + * The ID of the invoked model. |
| 84 | + */ |
| 85 | + invokedModelId?: string; |
| 86 | + }; |
| 87 | + }; |
| 88 | + usage?: { |
| 89 | + /** |
| 90 | + * The number of tokens that were read from the cache. |
| 91 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock#cache-points |
| 92 | + */ |
| 93 | + cacheReadInputTokens?: number; |
| 94 | + |
| 95 | + /** |
| 96 | + * The number of tokens that were written to the cache. |
| 97 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock#cache-points |
| 98 | + */ |
| 99 | + cacheWriteInputTokens?: number; |
| 100 | + }; |
| 101 | +} |
| 102 | + |
| 103 | +/** |
| 104 | + * Google Generative AI Provider Metadata |
| 105 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai |
| 106 | + */ |
| 107 | +export interface GoogleGenerativeAIProviderMetadata { |
| 108 | + /** |
| 109 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/google/src/google-generative-ai-prompt.ts#L28-L30 |
| 110 | + */ |
| 111 | + groundingMetadata: null | { |
| 112 | + /** |
| 113 | + * Array of search queries used to retrieve information |
| 114 | + * @example ["What's the weather in Chicago this weekend?"] |
| 115 | + * |
| 116 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai#search-grounding |
| 117 | + */ |
| 118 | + webSearchQueries: string[] | null; |
| 119 | + /** |
| 120 | + * Contains the main search result content used as an entry point |
| 121 | + * The `renderedContent` field contains the formatted content |
| 122 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai#search-grounding |
| 123 | + */ |
| 124 | + searchEntryPoint?: { |
| 125 | + renderedContent: string; |
| 126 | + } | null; |
| 127 | + /** |
| 128 | + * Contains details about how specific response parts are supported by search results |
| 129 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai#search-grounding |
| 130 | + */ |
| 131 | + groundingSupports: Array<{ |
| 132 | + /** |
| 133 | + * Information about the grounded text segment. |
| 134 | + */ |
| 135 | + segment: { |
| 136 | + /** |
| 137 | + * The start index of the text segment. |
| 138 | + */ |
| 139 | + startIndex?: number | null; |
| 140 | + /** |
| 141 | + * The end index of the text segment. |
| 142 | + */ |
| 143 | + endIndex?: number | null; |
| 144 | + /** |
| 145 | + * The actual text segment. |
| 146 | + */ |
| 147 | + text?: string | null; |
| 148 | + }; |
| 149 | + /** |
| 150 | + * References to supporting search result chunks. |
| 151 | + */ |
| 152 | + groundingChunkIndices?: number[] | null; |
| 153 | + /** |
| 154 | + * Confidence scores (0-1) for each supporting chunk. |
| 155 | + */ |
| 156 | + confidenceScores?: number[] | null; |
| 157 | + }> | null; |
| 158 | + }; |
| 159 | + /** |
| 160 | + * @see https://github.com/vercel/ai/blob/65e042afde6aad4da9d7a62526ece839eb34f9a5/packages/google/src/google-generative-ai-language-model.ts#L620-L627 |
| 161 | + * @see https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters |
| 162 | + */ |
| 163 | + safetyRatings?: null | unknown; |
| 164 | +} |
| 165 | + |
| 166 | +/** |
| 167 | + * DeepSeek Provider Metadata |
| 168 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/deepseek |
| 169 | + */ |
| 170 | +interface DeepSeekProviderMetadata { |
| 171 | + /** |
| 172 | + * The number of tokens that were cache hits. |
| 173 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/deepseek#cache-token-usage |
| 174 | + */ |
| 175 | + promptCacheHitTokens?: number; |
| 176 | + |
| 177 | + /** |
| 178 | + * The number of tokens that were cache misses. |
| 179 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/deepseek#cache-token-usage |
| 180 | + */ |
| 181 | + promptCacheMissTokens?: number; |
| 182 | +} |
| 183 | + |
| 184 | +/** |
| 185 | + * Perplexity Provider Metadata |
| 186 | + * @see https://ai-sdk.dev/providers/ai-sdk-providers/perplexity |
| 187 | + */ |
| 188 | +interface PerplexityProviderMetadata { |
| 189 | + /** |
| 190 | + * Object containing citationTokens and numSearchQueries metrics |
| 191 | + */ |
| 192 | + usage?: { |
| 193 | + citationTokens?: number; |
| 194 | + numSearchQueries?: number; |
| 195 | + }; |
| 196 | + /** |
| 197 | + * Array of image URLs when return_images is enabled. |
| 198 | + * |
| 199 | + * You can enable image responses by setting return_images: true in the provider options. |
| 200 | + * This feature is only available to Perplexity Tier-2 users and above. |
| 201 | + */ |
| 202 | + images?: Array<{ |
| 203 | + imageUrl?: string; |
| 204 | + originUrl?: string; |
| 205 | + height?: number; |
| 206 | + width?: number; |
| 207 | + }>; |
| 208 | +} |
| 209 | + |
| 210 | +export interface ProviderMetadata { |
| 211 | + openai?: OpenAiProviderMetadata; |
| 212 | + anthropic?: AnthropicProviderMetadata; |
| 213 | + bedrock?: AmazonBedrockProviderMetadata; |
| 214 | + google?: GoogleGenerativeAIProviderMetadata; |
| 215 | + deepseek?: DeepSeekProviderMetadata; |
| 216 | + perplexity?: PerplexityProviderMetadata; |
| 217 | +} |
0 commit comments