Skip to content

fix(ai-bedrock): use /openai/v1 on mantle for google.gemma - #1270

Open
harshlocham wants to merge 3 commits into
TanStack:mainfrom
harshlocham:fix-925-bedrock-mantle-path
Open

fix(ai-bedrock): use /openai/v1 on mantle for google.gemma#1270
harshlocham wants to merge 3 commits into
TanStack:mainfrom
harshlocham:fix-925-bedrock-mantle-path

Conversation

@harshlocham

@harshlocham harshlocham commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

On the Bedrock Mantle endpoint, Gemma 4 models are served at /openai/v1. The adapter always used /v1, so the request failed with a misleading 401. This change sends google.gemma-4-* to /openai/v1. An explicit baseURL still wins.

Fixes #925

🎯 Changes

withBedrockDefaults now takes an optional model id. On mantle, ids that start with google.gemma- use /openai/v1. Other models keep /v1. The chat and responses adapters pass the model id. The runtime endpoint path does not change.

Out of scope: Claude on mantle (/anthropic/v1/messages is a different API). Gemma is still absent from the generated catalog, so bedrockText('google.gemma-4-31b', { api: 'chat' }) still fails the chat-model check until that entry exists.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Bedrock Mantle routing for google.gemma-4-* models by using the /openai/v1 path.
    • Preserved /v1 routing for Gemma 3 and other models.
    • Prevented misleading authentication errors while preserving custom base URL overrides.
  • Documentation

    • Clarified Mantle endpoint paths by model family.
  • Tests

    • Added coverage for model matching, routing paths, runtime endpoints, and custom base URLs.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 54b34e7e-a7c2-4c9b-acb8-2eb607b1612d

📥 Commits

Reviewing files that changed from the base of the PR and between c705bc7 and 6117a15.

📒 Files selected for processing (6)
  • .changeset/bumpy-news-sing.md
  • docs/adapters/bedrock.md
  • packages/ai-bedrock/src/adapters/responses-text.ts
  • packages/ai-bedrock/src/adapters/text.ts
  • packages/ai-bedrock/src/utils/client.ts
  • packages/ai-bedrock/tests/client.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/ai-bedrock/src/adapters/responses-text.ts
  • packages/ai-bedrock/tests/client.test.ts
  • .changeset/bumpy-news-sing.md
  • packages/ai-bedrock/src/utils/client.ts
  • packages/ai-bedrock/src/adapters/text.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Bedrock client now selects /openai/v1 for google.gemma-4-* models on Mantle. Both Bedrock adapters pass the model to client configuration. Tests, documentation, and the changeset cover the routing behavior.

Changes

Bedrock Gemma Mantle path

Layer / File(s) Summary
Model-aware base URL resolution
packages/ai-bedrock/src/utils/client.ts
buildBaseURL selects /openai/v1 only for google.gemma-4-* models on Mantle. Other models use /v1. Runtime paths and explicit baseURL overrides remain unchanged.
Adapter wiring and path validation
packages/ai-bedrock/src/adapters/text.ts, packages/ai-bedrock/src/adapters/responses-text.ts, packages/ai-bedrock/tests/client.test.ts, docs/adapters/bedrock.md, .changeset/bumpy-news-sing.md
Both adapters pass the model name to withBedrockDefaults. Tests cover Gemma 4, Gemma 3, other models, prefix matching, runtime paths, and explicit base URLs. Documentation and the changeset describe the new path selection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 6117a

This localized change adjusts the Bedrock Mantle path for Gemma models while preserving explicit base URLs and existing paths for other models; no actionable merge-blocking risk remains.

Suggested reviewers: tombeckenham

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: routing Google Gemma requests through /openai/v1 on Bedrock Mantle.
Description check ✅ Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains the cause, implementation, scope limits, testing, documentation, and changeset status.
Linked Issues check ✅ Passed The PR addresses the Gemma routing requirement from issue #925. It selects /openai/v1 for Gemma 4 models, retains /v1 for other models, preserves explicit baseURL precedence, and leaves the runtime en…
Out of Scope Changes check ✅ Passed The code, tests, documentation, and changeset changes directly support the Gemma 4 Bedrock Mantle routing fix. No unrelated changes are present.
Full details: Linked Issues check

Explanation

The PR addresses the Gemma routing requirement from issue #925. It selects /openai/v1 for Gemma 4 models, retains /v1 for other models, preserves explicit baseURL precedence, and leaves the runtime endpoint path unchanged. Claude Mantle support and catalog changes are explicitly outside this PR's stated scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/ai-bedrock/src/utils/client.ts Outdated
@github-actions github-actions Bot added the waiting-on: maintainer The ball is in the maintainers’ court label Aug 30, 2026
@nx-cloud

nx-cloud Bot commented Aug 30, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 73aec31

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 5s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 24s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-31 21:44:46 UTC

@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@1270

@tanstack/ai-acp

npm i https://pkg.pr.new/@tanstack/ai-acp@1270

@tanstack/ai-angular

npm i https://pkg.pr.new/@tanstack/ai-angular@1270

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@1270

@tanstack/ai-bedrock

npm i https://pkg.pr.new/@tanstack/ai-bedrock@1270

@tanstack/ai-byteplus

npm i https://pkg.pr.new/@tanstack/ai-byteplus@1270

@tanstack/ai-claude-code

npm i https://pkg.pr.new/@tanstack/ai-claude-code@1270

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@1270

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@1270

@tanstack/ai-code-mode-snippets

npm i https://pkg.pr.new/@tanstack/ai-code-mode-snippets@1270

@tanstack/ai-codex

npm i https://pkg.pr.new/@tanstack/ai-codex@1270

@tanstack/ai-cohere

npm i https://pkg.pr.new/@tanstack/ai-cohere@1270

@tanstack/ai-compaction

npm i https://pkg.pr.new/@tanstack/ai-compaction@1270

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@1270

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/@tanstack/ai-durable-stream@1270

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@1270

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@1270

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@1270

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@1270

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@1270

@tanstack/ai-grok-build

npm i https://pkg.pr.new/@tanstack/ai-grok-build@1270

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@1270

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@1270

@tanstack/ai-isolate-daytona

npm i https://pkg.pr.new/@tanstack/ai-isolate-daytona@1270

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@1270

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@1270

@tanstack/ai-isolate-quickjs-bun

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs-bun@1270

@tanstack/ai-llmgateway

npm i https://pkg.pr.new/@tanstack/ai-llmgateway@1270

@tanstack/ai-lovable

npm i https://pkg.pr.new/@tanstack/ai-lovable@1270

@tanstack/ai-mcp

npm i https://pkg.pr.new/@tanstack/ai-mcp@1270

@tanstack/ai-memory

npm i https://pkg.pr.new/@tanstack/ai-memory@1270

@tanstack/ai-mistral

npm i https://pkg.pr.new/@tanstack/ai-mistral@1270

@tanstack/ai-octane

npm i https://pkg.pr.new/@tanstack/ai-octane@1270

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@1270

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@1270

@tanstack/ai-opencode

npm i https://pkg.pr.new/@tanstack/ai-opencode@1270

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@1270

@tanstack/ai-perplexity

npm i https://pkg.pr.new/@tanstack/ai-perplexity@1270

@tanstack/ai-persistence

npm i https://pkg.pr.new/@tanstack/ai-persistence@1270

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@1270

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@1270

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@1270

@tanstack/ai-sandbox

npm i https://pkg.pr.new/@tanstack/ai-sandbox@1270

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-sandbox-cloudflare@1270

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/@tanstack/ai-sandbox-daytona@1270

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/@tanstack/ai-sandbox-docker@1270

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/@tanstack/ai-sandbox-local-process@1270

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/@tanstack/ai-sandbox-sprites@1270

@tanstack/ai-sandbox-upstash-box

npm i https://pkg.pr.new/@tanstack/ai-sandbox-upstash-box@1270

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/@tanstack/ai-sandbox-vercel@1270

@tanstack/ai-skills

npm i https://pkg.pr.new/@tanstack/ai-skills@1270

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@1270

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@1270

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@1270

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@1270

@tanstack/ai-vercel-gateway

npm i https://pkg.pr.new/@tanstack/ai-vercel-gateway@1270

@tanstack/ai-vertex

npm i https://pkg.pr.new/@tanstack/ai-vertex@1270

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@1270

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@1270

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@1270

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@1270

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@1270

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@1270

@tanstack/svelte-ai-devtools

npm i https://pkg.pr.new/@tanstack/svelte-ai-devtools@1270

commit: 73aec31

@AlemTuzlak AlemTuzlak added the ai-review Have an agent review the PR label Aug 31, 2026
@tombeckenham
tombeckenham force-pushed the fix-925-bedrock-mantle-path branch from 7566bec to 73aec31 Compare August 31, 2026 21:24
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR, @harshlocham! 🙌 @tombeckenham will take a look.

Automated pre-review checks

  • ⚠️ CI failing — worth a look before review
  • ✅ No merge conflicts
  • ✅ Changeset present
  • ⚠️ No E2E test changes detected — behavior changes need coverage under testing/e2e/ (see CONTRIBUTING)

Automated triage — a human review follows.

@github-actions github-actions Bot added waiting-on: author Waiting for the author to respond or update and removed waiting-on: maintainer The ball is in the maintainers’ court labels Sep 1, 2026
harshlocham and others added 3 commits September 1, 2026 21:20
- Introduced a new changeset to specify that `google.gemma-*` models now use the `/openai/v1` path on the Bedrock Mantle endpoint, ensuring correct routing for chat and response requests.
- Updated documentation to reflect the new endpoint behavior for Gemma models.
- Modified the `buildBaseURL` function to dynamically set the base URL based on the model type.
- Enhanced tests to verify the correct base URL is used for both Gemma and other models on the mantle endpoint.
- Updated the Bedrock Mantle endpoint to specify that only `google.gemma-4-*` models use the `/openai/v1` path, while `google.gemma-3-*` models continue to use `/v1`.
- Adjusted documentation to clarify the endpoint behavior for different Gemma model versions.
- Enhanced tests to ensure correct base URL handling for both Gemma 3 and Gemma 4 models.
@harshlocham
harshlocham force-pushed the fix-925-bedrock-mantle-path branch from 73aec31 to 6117a15 Compare September 1, 2026 15:50
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions github-actions Bot added waiting-on: maintainer The ball is in the maintainers’ court and removed waiting-on: author Waiting for the author to respond or update labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Have an agent review the PR waiting-on: maintainer The ball is in the maintainers’ court

Projects

None yet

4 participants