Skip to content

Commit 0f2b2f1

Browse files
Backport: fix(provider/google): fix Gemini service tier enum after upstream update (#14091)
This is an automated backport of #14090 to the release-v6.0 branch. FYI @felixarntz Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
1 parent ffd431a commit 0f2b2f1

6 files changed

Lines changed: 17 additions & 18 deletions

File tree

.changeset/cold-avocados-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ai-sdk/google": patch
3+
---
4+
5+
fix(provider/google): fix Gemini service tier enum after upstream update

content/providers/01-ai-sdk-providers/15-google-generative-ai.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ The following optional provider options are available for Google Generative AI m
245245
Optional. Defines labels used in billing reports. Available on Vertex AI only.
246246
See [Google Cloud labels documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls).
247247

248-
- **serviceTier** _'SERVICE_TIER_STANDARD' | 'SERVICE_TIER_FLEX' | 'SERVICE_TIER_PRIORITY'_
248+
- **serviceTier** _'standard' | 'flex' | 'priority'_
249249

250250
Optional. The service tier to use for the request.
251-
Set to 'SERVICE_TIER_FLEX' for 50% cheaper processing at the cost of increased latency.
252-
Set to 'SERVICE_TIER_PRIORITY' for ultra-low latency at a 75-100% price premium over 'SERVICE_TIER_STANDARD'.
251+
Set to 'flex' for 50% cheaper processing at the cost of increased latency.
252+
Set to 'priority' for ultra-low latency at a 75-100% price premium over 'standard'.
253253

254254
- **threshold** _string_
255255

examples/ai-functions/src/generate-text/google/service-tier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ run(async () => {
88
prompt: 'What color is the sky in one word?',
99
providerOptions: {
1010
google: {
11-
serviceTier: 'SERVICE_TIER_FLEX',
11+
serviceTier: 'flex',
1212
} satisfies GoogleLanguageModelOptions,
1313
},
1414
});

examples/ai-functions/src/stream-text/google/service-tier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ run(async () => {
88
prompt: 'What color is the sky in one word?',
99
providerOptions: {
1010
google: {
11-
serviceTier: 'SERVICE_TIER_FLEX',
11+
serviceTier: 'priority',
1212
} satisfies GoogleLanguageModelOptions,
1313
},
1414
});

packages/google/src/google-generative-ai-language-model.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,13 @@ describe('doGenerate', () => {
566566
prompt: TEST_PROMPT,
567567
providerOptions: {
568568
google: {
569-
serviceTier: 'SERVICE_TIER_FLEX',
569+
serviceTier: 'flex',
570570
},
571571
},
572572
});
573573

574574
expect(await server.calls[0].requestBodyJson).toMatchObject({
575-
serviceTier: 'SERVICE_TIER_FLEX',
575+
serviceTier: 'flex',
576576
});
577577
});
578578

@@ -606,15 +606,15 @@ describe('doGenerate', () => {
606606
candidatesTokenCount: 2,
607607
totalTokenCount: 3,
608608
},
609-
serviceTier: 'SERVICE_TIER_FLEX',
609+
serviceTier: 'flex',
610610
},
611611
};
612612

613613
const { providerMetadata } = await model.doGenerate({
614614
prompt: TEST_PROMPT,
615615
});
616616

617-
expect(providerMetadata?.google.serviceTier).toBe('SERVICE_TIER_FLEX');
617+
expect(providerMetadata?.google.serviceTier).toBe('flex');
618618
});
619619

620620
it('should expose null serviceTier in provider metadata when not present', async () => {
@@ -4014,7 +4014,7 @@ describe('doStream', () => {
40144014
candidatesTokenCount: 2,
40154015
totalTokenCount: 3,
40164016
},
4017-
serviceTier: 'SERVICE_TIER_FLEX',
4017+
serviceTier: 'flex',
40184018
})}\n\n`,
40194019
],
40204020
};
@@ -4029,7 +4029,7 @@ describe('doStream', () => {
40294029
expect(
40304030
finishEvent?.type === 'finish' &&
40314031
finishEvent.providerMetadata?.google.serviceTier,
4032-
).toBe('SERVICE_TIER_FLEX');
4032+
).toBe('flex');
40334033
});
40344034

40354035
it('should expose null serviceTier in provider metadata on finish when not present', async () => {

packages/google/src/google-generative-ai-options.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,7 @@ export const googleLanguageModelOptions = lazySchema(() =>
192192
/**
193193
* Optional. The service tier to use for the request.
194194
*/
195-
serviceTier: z
196-
.enum([
197-
'SERVICE_TIER_STANDARD',
198-
'SERVICE_TIER_FLEX',
199-
'SERVICE_TIER_PRIORITY',
200-
])
201-
.optional(),
195+
serviceTier: z.enum(['standard', 'flex', 'priority']).optional(),
202196
}),
203197
),
204198
);

0 commit comments

Comments
 (0)