@ai-sdk/google-vertex 4.0.27 → 4.0.29

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 4.0.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [462ad00]
8
+ - @ai-sdk/provider-utils@4.0.10
9
+ - @ai-sdk/anthropic@3.0.24
10
+ - @ai-sdk/google@3.0.14
11
+
12
+ ## 4.0.28
13
+
14
+ ### Patch Changes
15
+
16
+ - 4de5a1d: chore: excluded tests from src folder in npm package
17
+ - Updated dependencies [4de5a1d]
18
+ - @ai-sdk/anthropic@3.0.23
19
+ - @ai-sdk/google@3.0.13
20
+ - @ai-sdk/provider@3.0.5
21
+ - @ai-sdk/provider-utils@4.0.9
22
+
3
23
  ## 4.0.27
4
24
 
5
25
  ### Patch Changes
@@ -32,7 +32,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
32
  var import_provider_utils = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "4.0.27" : "0.0.0-test";
35
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
36
36
 
37
37
  // src/edge/google-vertex-auth-edge.ts
38
38
  var loadCredentials = async () => {
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "4.0.27" : "0.0.0-test";
13
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -33,7 +33,7 @@ var import_internal2 = require("@ai-sdk/google/internal");
33
33
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
34
34
 
35
35
  // src/version.ts
36
- var VERSION = true ? "4.0.27" : "0.0.0-test";
36
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
37
37
 
38
38
  // src/google-vertex-embedding-model.ts
39
39
  var import_provider = require("@ai-sdk/provider");
@@ -14,7 +14,7 @@ import {
14
14
  } from "@ai-sdk/provider-utils";
15
15
 
16
16
  // src/version.ts
17
- var VERSION = true ? "4.0.27" : "0.0.0-test";
17
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
18
18
 
19
19
  // src/google-vertex-embedding-model.ts
20
20
  import {
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ var import_internal2 = require("@ai-sdk/google/internal");
55
55
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
56
56
 
57
57
  // src/version.ts
58
- var VERSION = true ? "4.0.27" : "0.0.0-test";
58
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
59
59
 
60
60
  // src/google-vertex-embedding-model.ts
61
61
  var import_provider = require("@ai-sdk/provider");
package/dist/index.mjs CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  } from "@ai-sdk/provider-utils";
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.27" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
39
39
 
40
40
  // src/google-vertex-embedding-model.ts
41
41
  import {
@@ -287,6 +287,11 @@ await generateText({
287
287
 
288
288
  The following optional provider options are available for Google Vertex models:
289
289
 
290
+ - **cachedContent** _string_
291
+
292
+ Optional. The name of the cached content used as context to serve the prediction.
293
+ Format: projects/\{project\}/locations/\{location\}/cachedContents/\{cachedContent\}
294
+
290
295
  - **structuredOutputs** _boolean_
291
296
 
292
297
  Optional. Enable structured output. Default is true.
@@ -546,6 +551,109 @@ const { text } = await generateText({
546
551
 
547
552
  See [File Parts](/docs/foundations/prompts#file-parts) for details on how to use files in prompts.
548
553
 
554
+ ### Cached Content
555
+
556
+ Google Vertex AI supports both explicit and implicit caching to help reduce costs on repetitive content.
557
+
558
+ #### Implicit Caching
559
+
560
+ ```ts
561
+ import { vertex } from '@ai-sdk/google-vertex';
562
+ import { generateText } from 'ai';
563
+
564
+ // Structure prompts with consistent content at the beginning
565
+ const baseContext =
566
+ 'You are a cooking assistant with expertise in Italian cuisine. Here are 1000 lasagna recipes for reference...';
567
+
568
+ const { text: veggieLasagna } = await generateText({
569
+ model: vertex('gemini-2.5-pro'),
570
+ prompt: `${baseContext}\n\nWrite a vegetarian lasagna recipe for 4 people.`,
571
+ });
572
+
573
+ // Second request with same prefix - eligible for cache hit
574
+ const { text: meatLasagna, providerMetadata } = await generateText({
575
+ model: vertex('gemini-2.5-pro'),
576
+ prompt: `${baseContext}\n\nWrite a meat lasagna recipe for 12 people.`,
577
+ });
578
+
579
+ // Check cached token count in usage metadata
580
+ console.log('Cached tokens:', providerMetadata.google);
581
+ // e.g.
582
+ // {
583
+ // groundingMetadata: null,
584
+ // safetyRatings: null,
585
+ // usageMetadata: {
586
+ // cachedContentTokenCount: 2027,
587
+ // thoughtsTokenCount: 702,
588
+ // promptTokenCount: 2152,
589
+ // candidatesTokenCount: 710,
590
+ // totalTokenCount: 3564
591
+ // }
592
+ // }
593
+ ```
594
+
595
+ #### Explicit Caching
596
+
597
+ You can use explicit caching with Gemini models. See the [Vertex AI context caching documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview) to check if caching is supported for your model.
598
+
599
+ First, create a cache using the Google GenAI SDK with Vertex mode enabled:
600
+
601
+ ```ts
602
+ import { GoogleGenAI } from '@google/genai';
603
+
604
+ const ai = new GoogleGenAI({
605
+ vertexai: true,
606
+ project: process.env.GOOGLE_VERTEX_PROJECT,
607
+ location: process.env.GOOGLE_VERTEX_LOCATION,
608
+ });
609
+
610
+ const model = 'gemini-2.5-pro';
611
+
612
+ // Create a cache with the content you want to reuse
613
+ const cache = await ai.caches.create({
614
+ model,
615
+ config: {
616
+ contents: [
617
+ {
618
+ role: 'user',
619
+ parts: [{ text: '1000 Lasagna Recipes...' }],
620
+ },
621
+ ],
622
+ ttl: '300s', // Cache expires after 5 minutes
623
+ },
624
+ });
625
+
626
+ console.log('Cache created:', cache.name);
627
+ // e.g. projects/my-project/locations/us-central1/cachedContents/abc123
628
+ ```
629
+
630
+ Then use the cache with the AI SDK:
631
+
632
+ ```ts
633
+ import { vertex } from '@ai-sdk/google-vertex';
634
+ import { generateText } from 'ai';
635
+
636
+ const { text: veggieLasagnaRecipe } = await generateText({
637
+ model: vertex('gemini-2.5-pro'),
638
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
639
+ providerOptions: {
640
+ google: {
641
+ cachedContent: cache.name,
642
+ },
643
+ },
644
+ });
645
+
646
+ const { text: meatLasagnaRecipe } = await generateText({
647
+ model: vertex('gemini-2.5-pro'),
648
+ prompt: 'Write a meat lasagna recipe for 12 people.',
649
+ providerOptions: {
650
+ google: {
651
+ cachedContent: cache.name,
652
+ },
653
+ },
654
+ });
655
+ ```
656
+
549
657
  ### Safety Ratings
550
658
 
551
659
  The safety ratings provide insight into the safety of the model's response.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "4.0.27",
3
+ "version": "4.0.29",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,10 @@
10
10
  "dist/**/*",
11
11
  "docs/**/*",
12
12
  "src",
13
+ "!src/**/*.test.ts",
14
+ "!src/**/*.test-d.ts",
15
+ "!src/**/__snapshots__",
16
+ "!src/**/__fixtures__",
13
17
  "CHANGELOG.md",
14
18
  "README.md",
15
19
  "edge.d.ts",
@@ -44,17 +48,17 @@
44
48
  },
45
49
  "dependencies": {
46
50
  "google-auth-library": "^10.5.0",
47
- "@ai-sdk/anthropic": "3.0.22",
48
- "@ai-sdk/google": "3.0.12",
49
- "@ai-sdk/provider": "3.0.4",
50
- "@ai-sdk/provider-utils": "4.0.8"
51
+ "@ai-sdk/anthropic": "3.0.24",
52
+ "@ai-sdk/provider": "3.0.5",
53
+ "@ai-sdk/provider-utils": "4.0.10",
54
+ "@ai-sdk/google": "3.0.14"
51
55
  },
52
56
  "devDependencies": {
53
57
  "@types/node": "20.17.24",
54
58
  "tsup": "^8",
55
59
  "typescript": "5.8.3",
56
60
  "zod": "3.25.76",
57
- "@ai-sdk/test-server": "1.0.2",
61
+ "@ai-sdk/test-server": "1.0.3",
58
62
  "@vercel/ai-tsconfig": "0.0.0"
59
63
  },
60
64
  "peerDependencies": {
@@ -1,39 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`GoogleVertexEmbeddingModel > should expose the raw response 1`] = `
4
- {
5
- "body": {
6
- "predictions": [
7
- {
8
- "embeddings": {
9
- "statistics": {
10
- "token_count": 1,
11
- },
12
- "values": [
13
- 0.1,
14
- 0.2,
15
- 0.3,
16
- ],
17
- },
18
- },
19
- {
20
- "embeddings": {
21
- "statistics": {
22
- "token_count": 1,
23
- },
24
- "values": [
25
- 0.4,
26
- 0.5,
27
- 0.6,
28
- ],
29
- },
30
- },
31
- ],
32
- },
33
- "headers": {
34
- "content-length": "159",
35
- "content-type": "application/json",
36
- "test-header": "test-value",
37
- },
38
- }
39
- `;
@@ -1,87 +0,0 @@
1
- import { resolve } from '@ai-sdk/provider-utils';
2
- import * as edgeAuth from '../../edge/google-vertex-auth-edge';
3
- import { createVertexAnthropic as createVertexAnthropicOriginal } from '../google-vertex-anthropic-provider';
4
- import { createVertexAnthropic as createVertexAnthropicEdge } from './google-vertex-anthropic-provider-edge';
5
- import { describe, beforeEach, expect, it, vi } from 'vitest';
6
-
7
- // Mock the imported modules
8
- vi.mock('../../edge/google-vertex-auth-edge', () => ({
9
- generateAuthToken: vi.fn().mockResolvedValue('mock-auth-token'),
10
- }));
11
-
12
- vi.mock('../google-vertex-anthropic-provider', () => ({
13
- createVertexAnthropic: vi.fn().mockImplementation(options => ({
14
- ...options,
15
- })),
16
- }));
17
-
18
- describe('google-vertex-anthropic-provider-edge', () => {
19
- beforeEach(() => {
20
- vi.clearAllMocks();
21
- });
22
-
23
- it('default headers function should return auth token', async () => {
24
- createVertexAnthropicEdge({ project: 'test-project' });
25
-
26
- const mockCreateVertex = vi.mocked(createVertexAnthropicOriginal);
27
- const passedOptions = mockCreateVertex.mock.calls[0][0];
28
-
29
- expect(mockCreateVertex).toHaveBeenCalledTimes(1);
30
- expect(typeof passedOptions?.headers).toBe('function');
31
-
32
- expect(await resolve(passedOptions?.headers)).toStrictEqual({
33
- Authorization: 'Bearer mock-auth-token',
34
- });
35
- });
36
-
37
- it('should use custom headers in addition to auth token when provided', async () => {
38
- createVertexAnthropicEdge({
39
- project: 'test-project',
40
- headers: async () => ({
41
- 'Custom-Header': 'custom-value',
42
- }),
43
- });
44
-
45
- const mockCreateVertex = vi.mocked(createVertexAnthropicOriginal);
46
- const passedOptions = mockCreateVertex.mock.calls[0][0];
47
-
48
- expect(mockCreateVertex).toHaveBeenCalledTimes(1);
49
- expect(typeof passedOptions?.headers).toBe('function');
50
- expect(await resolve(passedOptions?.headers)).toEqual({
51
- Authorization: 'Bearer mock-auth-token',
52
- 'Custom-Header': 'custom-value',
53
- });
54
- });
55
-
56
- it('should use edge auth token generator', async () => {
57
- createVertexAnthropicEdge({ project: 'test-project' });
58
-
59
- const mockCreateVertex = vi.mocked(createVertexAnthropicOriginal);
60
- const passedOptions = mockCreateVertex.mock.calls[0][0];
61
-
62
- // Verify the headers function actually calls generateAuthToken by checking its result
63
- expect(passedOptions?.headers).toBeDefined();
64
- await resolve(passedOptions?.headers);
65
- expect(edgeAuth.generateAuthToken).toHaveBeenCalled();
66
- });
67
-
68
- it('passes googleCredentials to generateAuthToken', async () => {
69
- createVertexAnthropicEdge({
70
- project: 'test-project',
71
- googleCredentials: {
72
- clientEmail: 'test@example.com',
73
- privateKey: 'test-key',
74
- },
75
- });
76
-
77
- const mockCreateVertex = vi.mocked(createVertexAnthropicOriginal);
78
- const passedOptions = mockCreateVertex.mock.calls[0][0];
79
-
80
- await resolve(passedOptions?.headers); // call the headers function
81
-
82
- expect(edgeAuth.generateAuthToken).toHaveBeenCalledWith({
83
- clientEmail: 'test@example.com',
84
- privateKey: 'test-key',
85
- });
86
- });
87
- });
@@ -1,73 +0,0 @@
1
- import { resolve } from '@ai-sdk/provider-utils';
2
- import { createVertexAnthropic as createVertexAnthropicOriginal } from './google-vertex-anthropic-provider';
3
- import { createVertexAnthropic as createVertexAnthropicNode } from './google-vertex-anthropic-provider-node';
4
- import { generateAuthToken } from '../google-vertex-auth-google-auth-library';
5
- import { describe, beforeEach, expect, it, vi } from 'vitest';
6
-
7
- // Mock the imported modules
8
- vi.mock('../google-vertex-auth-google-auth-library', () => ({
9
- generateAuthToken: vi.fn().mockResolvedValue('mock-auth-token'),
10
- }));
11
-
12
- vi.mock('./google-vertex-anthropic-provider', () => ({
13
- createVertexAnthropic: vi.fn().mockImplementation(options => ({
14
- ...options,
15
- })),
16
- }));
17
-
18
- describe('google-vertex-anthropic-provider-node', () => {
19
- beforeEach(() => {
20
- vi.clearAllMocks();
21
- });
22
-
23
- it('default headers function should return auth token', async () => {
24
- createVertexAnthropicNode({ project: 'test-project' });
25
-
26
- expect(createVertexAnthropicOriginal).toHaveBeenCalledTimes(1);
27
- const passedOptions = vi.mocked(createVertexAnthropicOriginal).mock
28
- .calls[0][0];
29
-
30
- expect(typeof passedOptions?.headers).toBe('function');
31
- expect(await resolve(passedOptions?.headers)).toStrictEqual({
32
- Authorization: 'Bearer mock-auth-token',
33
- });
34
- });
35
-
36
- it('should use custom headers in addition to auth token when provided', async () => {
37
- createVertexAnthropicNode({
38
- project: 'test-project',
39
- headers: async () => ({
40
- 'Custom-Header': 'custom-value',
41
- }),
42
- });
43
-
44
- expect(createVertexAnthropicOriginal).toHaveBeenCalledTimes(1);
45
- const passedOptions = vi.mocked(createVertexAnthropicOriginal).mock
46
- .calls[0][0];
47
-
48
- expect(await resolve(passedOptions?.headers)).toEqual({
49
- Authorization: 'Bearer mock-auth-token',
50
- 'Custom-Header': 'custom-value',
51
- });
52
- });
53
-
54
- it('passes googleAuthOptions to generateAuthToken', async () => {
55
- createVertexAnthropicNode({
56
- googleAuthOptions: {
57
- scopes: ['https://www.googleapis.com/auth/cloud-platform'],
58
- keyFile: 'path/to/key.json',
59
- },
60
- });
61
-
62
- expect(createVertexAnthropicOriginal).toHaveBeenCalledTimes(1);
63
- const passedOptions = vi.mocked(createVertexAnthropicOriginal).mock
64
- .calls[0][0];
65
-
66
- await resolve(passedOptions?.headers); // call the headers function
67
-
68
- expect(generateAuthToken).toHaveBeenCalledWith({
69
- scopes: ['https://www.googleapis.com/auth/cloud-platform'],
70
- keyFile: 'path/to/key.json',
71
- });
72
- });
73
- });
@@ -1,208 +0,0 @@
1
- import {
2
- createVertexAnthropic,
3
- vertexAnthropicTools,
4
- } from './google-vertex-anthropic-provider';
5
- import { NoSuchModelError } from '@ai-sdk/provider';
6
- import { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';
7
- import { vi, describe, beforeEach, it, expect } from 'vitest';
8
-
9
- // Mock the imported modules
10
- vi.mock('@ai-sdk/provider-utils', () => ({
11
- loadOptionalSetting: vi
12
- .fn()
13
- .mockImplementation(({ settingValue }) => settingValue),
14
- withoutTrailingSlash: vi.fn().mockImplementation(url => url),
15
- createJsonErrorResponseHandler: vi.fn(),
16
- createProviderToolFactory: vi.fn(),
17
- createProviderToolFactoryWithOutputSchema: vi.fn(),
18
- lazySchema: vi.fn(),
19
- zodSchema: vi.fn(),
20
- }));
21
-
22
- vi.mock('@ai-sdk/anthropic/internal', async () => {
23
- const originalModule = await vi.importActual('@ai-sdk/anthropic/internal');
24
- return {
25
- ...originalModule,
26
- AnthropicMessagesLanguageModel: vi.fn(),
27
- };
28
- });
29
-
30
- describe('google-vertex-anthropic-provider', () => {
31
- beforeEach(() => {
32
- vi.clearAllMocks();
33
- });
34
-
35
- it('should create a language model with default settings', () => {
36
- const provider = createVertexAnthropic({
37
- project: 'test-project',
38
- location: 'test-location',
39
- });
40
- provider('test-model-id');
41
-
42
- // Assert that the model constructor was called with the correct arguments
43
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
44
- 'test-model-id',
45
- expect.objectContaining({
46
- baseURL: expect.stringContaining(
47
- '/projects/test-project/locations/test-location/publishers/anthropic/models',
48
- ),
49
- provider: 'vertex.anthropic.messages',
50
- headers: expect.any(Object),
51
- buildRequestUrl: expect.any(Function),
52
- transformRequestBody: expect.any(Function),
53
- }),
54
- );
55
- });
56
-
57
- it('should throw an error when using new keyword', () => {
58
- const provider = createVertexAnthropic({ project: 'test-project' });
59
-
60
- expect(() => new (provider as any)('test-model-id')).toThrow(
61
- 'The Anthropic model function cannot be called with the new keyword.',
62
- );
63
- });
64
-
65
- it('should pass baseURL to the model when created', () => {
66
- const customBaseURL = 'https://custom-url.com';
67
- const provider = createVertexAnthropic({
68
- project: 'test-project',
69
- baseURL: customBaseURL,
70
- });
71
- provider('test-model-id');
72
-
73
- // Assert that the constructor was called with the correct baseURL
74
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
75
- expect.anything(), // modelId
76
- expect.objectContaining({
77
- baseURL: customBaseURL,
78
- }),
79
- );
80
- });
81
-
82
- it('should throw NoSuchModelError for textEmbeddingModel', () => {
83
- const provider = createVertexAnthropic({ project: 'test-project' });
84
-
85
- expect(() => provider.embeddingModel('invalid-model-id')).toThrow(
86
- NoSuchModelError,
87
- );
88
- });
89
-
90
- it('should include vertexAnthropicTools (subset of anthropicTools)', () => {
91
- const provider = createVertexAnthropic({ project: 'test-project' });
92
-
93
- expect(provider.tools).toBe(vertexAnthropicTools);
94
- expect(provider.tools).toHaveProperty('bash_20241022');
95
- expect(provider.tools).toHaveProperty('bash_20250124');
96
- expect(provider.tools).toHaveProperty('textEditor_20241022');
97
- expect(provider.tools).toHaveProperty('textEditor_20250124');
98
- expect(provider.tools).toHaveProperty('textEditor_20250429');
99
- expect(provider.tools).toHaveProperty('textEditor_20250728');
100
- expect(provider.tools).toHaveProperty('computer_20241022');
101
- expect(provider.tools).toHaveProperty('webSearch_20250305');
102
- expect(provider.tools).not.toHaveProperty('codeExecution_20250825');
103
- });
104
-
105
- it('should pass custom headers to the model constructor', () => {
106
- const customHeaders = { 'Custom-Header': 'custom-value' };
107
- const provider = createVertexAnthropic({
108
- project: 'test-project',
109
- headers: customHeaders,
110
- });
111
- provider('test-model-id');
112
-
113
- // Assert that the model constructor was called with the correct headers
114
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
115
- expect.anything(), // modelId
116
- expect.objectContaining({
117
- headers: customHeaders,
118
- }),
119
- );
120
- });
121
-
122
- it('should create a Google Vertex Anthropic provider instance with custom settings', () => {
123
- const customProvider = createVertexAnthropic({
124
- project: 'custom-project',
125
- location: 'custom-location',
126
- baseURL: 'https://custom.base.url',
127
- headers: { 'Custom-Header': 'value' },
128
- });
129
-
130
- expect(customProvider).toBeDefined();
131
- expect(typeof customProvider).toBe('function');
132
- expect(customProvider.languageModel).toBeDefined();
133
- });
134
-
135
- it('should not support URL sources to force base64 conversion', () => {
136
- const provider = createVertexAnthropic();
137
- provider('test-model-id');
138
-
139
- // Assert that the model constructor was called with supportedUrls function
140
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
141
- 'test-model-id',
142
- expect.objectContaining({
143
- supportedUrls: expect.any(Function),
144
- }),
145
- );
146
-
147
- // Get the actual config passed to the constructor
148
- const constructorCall = vi.mocked(AnthropicMessagesLanguageModel).mock
149
- .calls[vi.mocked(AnthropicMessagesLanguageModel).mock.calls.length - 1];
150
- const config = constructorCall[1];
151
-
152
- // Verify that supportedUrls returns empty object to force base64 conversion
153
- expect(config.supportedUrls?.()).toEqual({});
154
- });
155
-
156
- it('should use correct URL for global location', () => {
157
- const provider = createVertexAnthropic({
158
- project: 'test-project',
159
- location: 'global',
160
- });
161
- provider('test-model-id');
162
-
163
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
164
- 'test-model-id',
165
- expect.objectContaining({
166
- baseURL:
167
- 'https://aiplatform.googleapis.com/v1/projects/test-project/locations/global/publishers/anthropic/models',
168
- provider: 'vertex.anthropic.messages',
169
- }),
170
- );
171
- });
172
-
173
- it('should use region-prefixed URL for non-global locations', () => {
174
- const provider = createVertexAnthropic({
175
- project: 'test-project',
176
- location: 'us-east5',
177
- });
178
- provider('test-model-id');
179
-
180
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
181
- 'test-model-id',
182
- expect.objectContaining({
183
- baseURL:
184
- 'https://us-east5-aiplatform.googleapis.com/v1/projects/test-project/locations/us-east5/publishers/anthropic/models',
185
- provider: 'vertex.anthropic.messages',
186
- }),
187
- );
188
- });
189
-
190
- it('should support combining tools with structured outputs (inherited from Anthropic)', () => {
191
- const provider = createVertexAnthropic({
192
- project: 'test-project',
193
- location: 'us-east5',
194
- });
195
-
196
- // Create a model instance
197
- const model = provider('claude-3-5-sonnet-v2@20241022');
198
-
199
- // Verify the model was created using AnthropicMessagesLanguageModel
200
- // which already supports combining tools with structured outputs
201
- expect(AnthropicMessagesLanguageModel).toHaveBeenCalledWith(
202
- 'claude-3-5-sonnet-v2@20241022',
203
- expect.objectContaining({
204
- provider: 'vertex.anthropic.messages',
205
- }),
206
- );
207
- });
208
- });