diff --git a/packages/ai/src/providers/google-vertex-chat.ts b/packages/ai/src/providers/google-vertex-chat.ts index e2f9c1a415..eea7b2b8e5 100644 --- a/packages/ai/src/providers/google-vertex-chat.ts +++ b/packages/ai/src/providers/google-vertex-chat.ts @@ -1,8 +1,9 @@ import type { ProviderPackage } from "../provider-package" import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat" import type { RouteDefaultsInput } from "../route/client" -import { ProviderID, type ModelID, type ProviderOptions } from "../schema" +import { ProviderID, type ModelID } from "../schema" import { GoogleVertexShared } from "./google-vertex-shared" +import type { OpenAIProviderOptionsInput } from "./openai-options" export const id = ProviderID.make("google-vertex") @@ -11,6 +12,7 @@ export type Config = RouteDefaultsInput & readonly baseURL?: string readonly location?: string readonly project?: string + readonly providerOptions?: OpenAIProviderOptionsInput } export interface Settings extends ProviderPackage.Settings { @@ -19,7 +21,7 @@ export interface Settings extends ProviderPackage.Settings { readonly baseURL?: string readonly location?: string readonly project?: string - readonly providerOptions?: ProviderOptions + readonly providerOptions?: OpenAIProviderOptionsInput } const route = OpenAICompatibleChat.route.with({ @@ -56,7 +58,7 @@ export const configure = (input: Config = {}) => { const route = configuredRoute(input) return { id, - model: (modelID: string | ModelID) => route.model({ id: modelID }), + model: (modelID: string | ModelID) => route.model({ id: modelID }), configure, } } @@ -66,7 +68,7 @@ export const provider = { configure, } -export const model: ProviderPackage.Definition["model"] = (modelID, settings) => { +export const model: ProviderPackage.Definition["model"] = (modelID, settings) => { if (settings.apiKey !== undefined) throw new Error("Google Vertex Chat does not support API keys") return configure({ accessToken: settings.accessToken, diff --git a/packages/ai/test/provider-options/google-vertex-chat.types.ts b/packages/ai/test/provider-options/google-vertex-chat.types.ts new file mode 100644 index 0000000000..d64f0af14b --- /dev/null +++ b/packages/ai/test/provider-options/google-vertex-chat.types.ts @@ -0,0 +1,13 @@ +import { LLM } from "../../src" +import { GoogleVertexChat } from "../../src/providers" + +const model = GoogleVertexChat.configure({ accessToken: "test", project: "project" }).model("gemini") + +LLM.request({ model, prompt: "Hello", providerOptions: { openai: { serviceTier: "priority" } } }) + +LLM.request({ + model, + prompt: "Hello", + // @ts-expect-error Vertex OpenAI-compatible service tiers use the OpenAI union. + providerOptions: { openai: { serviceTier: "premium" } }, +})