Skip to content

feat: add avalanche stealth provider - #1705

Merged
steebchen merged 6 commits into
mainfrom
add-avalanche-provider
Feb 20, 2026
Merged

steebchen merged 6 commits into
mainfrom
add-avalanche-provider

Conversation

@steebchen

@steebchen steebchen commented Feb 20, 2026

Copy link
Copy Markdown
Member

Add avalanche stealth provider with Vertex-style authentication and URL structure.

Includes gemini-3-pro-image-preview, gemini-3-pro-preview, gemini-3-flash-preview, and gemini-3.1-pro-preview models with 20% discount. Requires LLM_AVALANCHE_API_KEY, LLM_AVALANCHE_BASE_URL, and LLM_AVALANCHE_PROJECT environment variables. Supports optional LLM_AVALANCHE_REGION (defaults to "global").

All gateway response processing handles avalanche alongside google-ai-studio and google-vertex providers for consistent behavior.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • New Features
    • Added Avalanche as a new provider with endpoint, header, and streaming support.
    • Integrated Avalanche into routing, auto-fallback, logging, and token accounting so it behaves like existing Google-style providers.
    • Added Avalanche model entries with pricing and capability metadata for multiple Gemini variants.

steebchen and others added 5 commits February 17, 2026 00:05
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add gemini-3-pro-preview and gemini-3.1-pro-preview to
avalanche. Use Vertex-style URL with project/region and
pass API key as query parameter instead of Bearer token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass token to getProviderEndpoint for avalanche provider
so key= query parameter is added to the URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 20, 2026 16:32
@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds "avalanche" as a Google-compatible provider across the gateway: routing, request/response transformation, streaming, token/accounting, endpoint/header construction, model/provider definitions, and extraction tools are updated so Avalanche follows the same code paths as Obsidian/Google providers.

Changes

Cohort / File(s) Summary
Chat Routing & Capabilities
apps/gateway/src/chat/chat.ts
Treats avalanche like Obsidian/Google in routing, uptime gating, streaming handling, token forwarding, and log enrichment branches.
Content / Image / Reasoning Extraction
apps/gateway/src/chat/tools/extract-content.ts, apps/gateway/src/chat/tools/extract-images.ts, apps/gateway/src/chat/tools/extract-reasoning.ts
Added avalanche to existing Obsidian switch cases so content, images, and reasoning follow the same extraction paths.
Token Usage & Tool Calls
apps/gateway/src/chat/tools/extract-token-usage.ts, apps/gateway/src/chat/tools/extract-tool-calls.ts
Included avalanche in Google-style token-usage and tool-call branches (uses usageMetadata and Google adjustments).
Provider Response Parsing & Transformation
apps/gateway/src/chat/tools/parse-provider-response.ts, apps/gateway/src/chat/tools/transform-response-to-openai.ts, apps/gateway/src/chat/tools/transform-streaming-to-openai.ts
Added avalanche as an alias in Google-style parsing and OpenAI transformation branches, including streaming transformations.
Costs & Logs
apps/gateway/src/lib/costs.ts, apps/gateway/src/lib/logs.ts
Expanded Google-style provider set to include avalanche for token accounting and unified finish-reason mappings (STOP→COMPLETED, UNKNOWN finish handling).
Provider Endpoint, Headers & Request Prep
packages/actions/src/get-provider-endpoint.ts, packages/actions/src/get-provider-headers.ts, packages/actions/src/prepare-request-body.ts
Added Avalanche endpoint construction (env vars: LLM_AVALANCHE_*) and header behavior; integrated avalanche into Google-compatible request body preparation and header logic.
Provider & Model Metadata
packages/models/src/providers.ts, packages/models/src/models/google.ts
Added avalanche provider entry and numerous Gemini-related skip-test model entries for Avalanche variants (pricing/feature metadata).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant Gateway as Gateway (router/transform)
participant Actions as Actions (endpoint/headers)
participant Provider as Avalanche/Google-Backend
participant Logs as Logs/Costs

Client->>Gateway: Send chat request (provider=avalanche)
Gateway->>Gateway: Recognize provider as Google-style (transform body)
Gateway->>Actions: build endpoint & headers (LLM_AVALANCHE_*)
Actions->>Provider: Forward request (stream or generate content)
Provider-->>Gateway: Return streaming/data responses
Gateway->>Logs: Enrich logs, compute tokens/costs
Gateway-->>Client: Return transformed OpenAI-compatible response

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • smakosh
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add avalanche stealth provider' clearly and concisely describes the main change: adding support for a new Avalanche provider to the system.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-avalanche-provider

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 and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Avalanche stealth provider, a Google Vertex-compatible LLM provider with authentication and URL structure following the Vertex AI pattern. The provider offers Gemini models (3-pro-preview, 3.1-pro-preview, 3-flash-preview, and 3-pro-image-preview) with a 20% discount compared to standard pricing.

Changes:

  • Added Avalanche provider configuration requiring API key, base URL, project, and optional region environment variables
  • Added four Gemini model variants for Avalanche provider with tiered pricing and 20% discount
  • Integrated Avalanche into all Google-style response processing logic for consistent behavior with other Google-compatible providers

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/models/src/providers.ts Added Avalanche provider definition with Vertex-style environment configuration
packages/models/src/models/google.ts Added Avalanche provider mappings for gemini-3-pro-preview, gemini-3.1-pro-preview, gemini-3-flash-preview, and gemini-3-pro-image-preview with pricing tiers and 20% discount
packages/actions/src/prepare-request-body.ts Added Avalanche to Google provider case for request body transformation
packages/actions/src/get-provider-headers.ts Added Avalanche to return empty headers (token passed via query parameter)
packages/actions/src/get-provider-endpoint.ts Added Avalanche endpoint generation with Vertex-style URL structure including project/region/publisher path
apps/gateway/src/lib/logs.ts Added Avalanche to Google provider checks for finish reason handling
apps/gateway/src/lib/costs.ts Added Avalanche to Google provider group for token counting and cost calculation
apps/gateway/src/chat/tools/transform-streaming-to-openai.ts Added Avalanche to Google provider case for streaming response transformation
apps/gateway/src/chat/tools/transform-response-to-openai.ts Added Avalanche to Google provider case for non-streaming response transformation
apps/gateway/src/chat/tools/parse-provider-response.ts Added Avalanche to Google provider case for response parsing
apps/gateway/src/chat/tools/extract-tool-calls.ts Added Avalanche to Google provider case for tool call extraction
apps/gateway/src/chat/tools/extract-token-usage.ts Added Avalanche to Google provider case for token usage extraction
apps/gateway/src/chat/tools/extract-reasoning.ts Added Avalanche to Google provider case for reasoning content extraction
apps/gateway/src/chat/tools/extract-images.ts Added Avalanche to Google provider case for image extraction
apps/gateway/src/chat/tools/extract-content.ts Added Avalanche to Google provider case for content extraction
apps/gateway/src/chat/chat.ts Added Avalanche to Google provider checks throughout chat handling for token passing, thought signature caching, web search counting, image counting, finish reason handling, and content filtering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/gateway/src/chat/tools/transform-streaming-to-openai.ts (1)

254-255: Optional: fix the hardcoded "google-ai-studio" in the extractImages call (line 431)

Adding obsidian and avalanche to this branch means line 431 now sends the wrong provider string to extractImages for two providers. It still works today because all four providers in this branch share the same code path in extractImages, but it's a latent correctness risk if those paths ever diverge.

♻️ Suggested fix
- delta.images = extractImages(data, "google-ai-studio");
+ delta.images = extractImages(data, usedProvider);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/gateway/src/chat/tools/transform-streaming-to-openai.ts` around lines
254 - 255, The switch branch that now handles case "obsidian" and case
"avalanche" is calling extractImages with a hardcoded provider string
"google-ai-studio"; update the call so it forwards the actual provider
identifier (the variable used in the switch) instead of the hardcoded literal.
Locate the cases for "obsidian"/"avalanche" and the extractImages(...)
invocation in transform-streaming-to-openai (the call site referencing
extractImages) and replace the static "google-ai-studio" argument with the
provider variable used in the surrounding function so each provider passes its
correct provider name to extractImages.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/models/src/models/google.ts`:
- Around line 767-803: The Avalanche entry for modelName
"gemini-3-flash-preview" (providerId "avalanche") has incorrect numeric
constants and an unexpected pricingTiers block: change contextSize from 1050000
to 1048576 and maxOutput from 65500 to 65535 to match sibling entries
(google-ai-studio/google-vertex), and remove the pricingTiers array entirely
unless Avalanche intentionally uses tiered pricing—if it is intentional, keep
the block but confirm the tier values are correct and documented.

---

Nitpick comments:
In `@apps/gateway/src/chat/tools/transform-streaming-to-openai.ts`:
- Around line 254-255: The switch branch that now handles case "obsidian" and
case "avalanche" is calling extractImages with a hardcoded provider string
"google-ai-studio"; update the call so it forwards the actual provider
identifier (the variable used in the switch) instead of the hardcoded literal.
Locate the cases for "obsidian"/"avalanche" and the extractImages(...)
invocation in transform-streaming-to-openai (the call site referencing
extractImages) and replace the static "google-ai-studio" argument with the
provider variable used in the surrounding function so each provider passes its
correct provider name to extractImages.

Comment thread packages/models/src/models/google.ts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/models/src/models/google.ts`:
- Around line 767-787: No change required: the model entry object for modelName
"gemini-3-flash-preview" already has corrected fields (contextSize, maxOutput,
pricing/flags) matching the google-ai-studio/vertex siblings; leave the object
(test/providerId/modelName/inputPrice/outputPrice/cachedInputPrice/requestPrice/discount/contextSize/maxOutput/reasoning/reasoningMaxTokens/streaming/vision/tools/webSearch/webSearchPrice/jsonOutput/jsonOutputSchema)
as-is and approve the change.

@steebchen
steebchen merged commit e628554 into main Feb 20, 2026
13 checks passed
@steebchen
steebchen deleted the add-avalanche-provider branch February 20, 2026 16:59
This was referenced Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants