@ai-sdk/google-vertex
Version:
The **[Google Vertex provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs.
15 lines (12 loc) • 444 B
text/typescript
import { GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';
export function createAuthTokenGenerator(options?: GoogleAuthOptions) {
const auth = new GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
...options,
});
return async function generateAuthToken() {
const client = await auth.getClient();
const token = await client.getAccessToken();
return token?.token ?? null;
};
}