@ai-sdk/google 4.0.73 → 4.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2304,3 +2304,54 @@ const result = await generateSpeech({
2304
2304
  | `gemini-2.5-flash-preview-tts` | <Check /> | <Check /> |
2305
2305
  | `gemini-2.5-pro-preview-tts` | <Check /> | <Check /> |
2306
2306
  | `gemini-3.1-flash-tts-preview` | <Check /> | <Check /> |
2307
+
2308
+ ## Evaluation Models
2309
+
2310
+ Create an experimental evaluation model with `google.evaluationModel(modelId)`.
2311
+ It uses Gemini structured output for Choice, Score, and Boolean questions. Choose a model
2312
+ that supports structured output, such as `gemini-3.5-flash-lite`.
2313
+
2314
+ ```ts
2315
+ import { google } from '@ai-sdk/google';
2316
+ import { experimental_evaluate } from 'ai';
2317
+
2318
+ const { answers } = await experimental_evaluate({
2319
+ model: google.evaluationModel('gemini-3.5-flash-lite'),
2320
+ state: 'I was charged twice.',
2321
+ questions: {
2322
+ requestsRefund: {
2323
+ type: 'boolean',
2324
+ instructions: 'Is the customer requesting money back?',
2325
+ },
2326
+ department: {
2327
+ type: 'choice',
2328
+ instructions: 'Which team should handle this?',
2329
+ criteria: { billing: 'Charges and refunds', support: 'Other requests' },
2330
+ },
2331
+ },
2332
+ providerOptions: {
2333
+ google: { thinkingConfig: { thinkingLevel: 'minimal' } },
2334
+ },
2335
+ });
2336
+ ```
2337
+
2338
+ The factory respects `createGoogle` settings and forwards `providerOptions.google`,
2339
+ including thinking configuration. Thinking controls depend on the selected model;
2340
+ use options supported by that model. The existing Gemini implementation sends the
2341
+ answer schema as `generationConfig.responseJsonSchema`.
2342
+
2343
+ Choice labels are returned exactly, and Scores are finite fractional positions
2344
+ within the ordered rubric. The adapter validates complete answers after parsing
2345
+ and rejects safety-blocked, truncated, or invalid output. It preserves usage
2346
+ (including reasoning tokens), warnings, response data, and provider metadata.
2347
+
2348
+ Choice and Score answers do not include probability distributions. Boolean
2349
+ answers contain prompted estimates of P(true), validated to be finite and in
2350
+ `[0, 1]`. These estimates are not guaranteed to be calibrated. Apply thresholds
2351
+ in application code, for example `answers.requestsRefund.probability >= 0.5`. See [Evaluation](/docs/ai-sdk-core/evaluation).
2352
+
2353
+ Evaluation models can also be accessed through `customProvider` aliases or
2354
+ `createProviderRegistry().evaluationModel('provider:model')`. Direct string IDs
2355
+ require an explicitly configured default provider with an `evaluationModel`
2356
+ method; they do not automatically use Gateway. See
2357
+ [model aliases and registries](/docs/ai-sdk-core/evaluation#model-aliases-and-registries).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.73",
3
+ "version": "4.0.74",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.16",
39
- "@ai-sdk/provider-utils": "5.0.42"
38
+ "@ai-sdk/provider": "4.0.17",
39
+ "@ai-sdk/provider-utils": "5.0.43"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.1",
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  EmbeddingModelV4,
3
3
  Experimental_BatchV4 as BatchV4,
4
+ Experimental_EvaluationModelV4 as EvaluationModelV4,
4
5
  Experimental_VideoModelV4,
5
6
  FilesV4,
6
7
  ImageModelV4,
@@ -20,6 +21,7 @@ import {
20
21
  type FetchFunction,
21
22
  type WebSocketConstructor,
22
23
  } from '@ai-sdk/provider-utils';
24
+ import { Experimental_EvaluationLanguageModel as EvaluationLanguageModel } from '@ai-sdk/provider-utils/experimental-evaluation';
23
25
  import { VERSION } from './version';
24
26
  import { GoogleEmbeddingModel } from './google-embedding-model';
25
27
  import type { GoogleEmbeddingModelId } from './google-embedding-model-options';
@@ -61,6 +63,9 @@ export interface GoogleProvider extends ProviderV4 {
61
63
 
62
64
  chat(modelId: GoogleModelId): LanguageModelV4;
63
65
 
66
+ /** Creates an experimental Choice/Score/Boolean evaluation model using Gemini. */
67
+ evaluationModel(modelId: GoogleModelId): EvaluationModelV4;
68
+
64
69
  experimental_batch(): BatchV4<{
65
70
  text: GoogleModelId;
66
71
  image: GoogleImageModelId;
@@ -430,6 +435,11 @@ export function createGoogle(
430
435
  provider.languageModel = createChatModel;
431
436
  provider.chat = createChatModel;
432
437
  provider.generativeAI = createChatModel;
438
+ provider.evaluationModel = (modelId: GoogleModelId) =>
439
+ new EvaluationLanguageModel({
440
+ model: createChatModel(modelId),
441
+ provider: `${providerName.replace(/\.generative-ai$/, '')}.evaluation`,
442
+ });
433
443
  provider.experimental_batch = createBatch;
434
444
  provider.embedding = createEmbeddingModel;
435
445
  provider.embeddingModel = createEmbeddingModel;