Skip to content

Conversation

@ResiDev
Copy link

@ResiDev ResiDev commented Dec 18, 2025

  • Remove hardcoded /v1beta/ prefix from all endpoint paths in Generated.ts GoogleClient.ts
  • Update default apiUrl in GoogleClient.ts to include /v1beta

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Summary

Move API version from hardcoded paths to configurable `apiUrl` default, enabling Vertex AI support.

Changes

  • Remove /v1beta/ prefix from paths in Generated.ts
  • Update default apiUrl to include /v1beta for backwards compatibility
  • Update streaming URL in GoogleClient.ts
  • Update JSDoc comments

Why

The hardcoded /v1beta/ in paths prevented using alternative endpoints like Vertex AI, which uses a different URL structure. This change makes the version configurable via apiUrl while maintaining full backwards compatibility.

It is also makes it easier to change the version should google change it from v1beta

Example

const baseHost = `${location === "global" ? "" : location + "-"}aiplatform.googleapis.com`
const vertexApiUrl = `https://${baseHost}/v1beta1/projects/${projectId}/locations/${location}/publishers/google`

const transformClient = (client: HttpClient.HttpClient) =>
  HttpClient.mapRequest(client, (request) =>
    HttpClientRequest.setHeader(request, "Authorization", `Bearer ${token}`)) // token from google-auth-library

const VertexGoogleClientLayer = GoogleClient.layer({
  apiUrl: vertexApiUrl, // now works because v1beta is not hardcoded
  transformClient
})

const ModelLayer = GoogleLanguageModel.layer({
  model: "gemini-3-flash-preview"
})

const FullLayer = Layer.provide(
  Layer.provide(ModelLayer, VertexGoogleClientLayer),
  FetchHttpClient.layer
)
// provide to Effect function

Testing

Tested with both standard Google Generative AI and Vertex AI endpoints.
Ran pnpm test, all related tests passed.

- Remove hardcoded /v1beta/ prefix from all endpoint paths in
Generated.ts GoogleClient.ts
- Update default apiUrl in GoogleClient.ts to include /v1beta
@ResiDev ResiDev requested a review from IMax153 as a code owner December 18, 2025 12:51
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Dec 18, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 48fe0c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/ai-google Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@IMax153
Copy link
Member

IMax153 commented Dec 18, 2025

A few comments / questions:

  1. Does the Vertex API share the same exact semantics as the Google Generative AI API? If not, this will not work and we will need a separate provider package
  2. The Generated.ts is generated from Google's OpenAPI spec - if we want the v1beta prefix then you'll need to update the generated.patch which is applied after codegen is complete on the OpenAPI spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

2 participants