Skip to content

How to use @google/genai with Vertex BYOK? #370

@hsab

Description

@hsab

I've been trying to understand how to get @google/genai working with BYOK/Unified Billing gateways.

The following works for unauthenticated gateways, but defeats the purpose of centralizing secrets since they need to be passed at client creation.

  client = new GoogleGenAI({
    vertexai: true,
    project: googleCredentials.project_id,
    location: 'global',
    googleAuthOptions: {
      credentials: {
        client_email: googleCredentials.client_email,
        private_key: googleCredentials.private_key,
      },
    },
    httpOptions: {
      baseUrl: `${CF_GATEWAY_BASE_URL({
        accountId: c.env.CF_ACCOUNT_ID,
        gatewayId: c.env.CF_AI_GATEWAY_UNAUTHED_ID,
      })}/google-vertex-ai`,
    },
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions