Skip to content

fix: send extra headers only for openrouter provider#87

Closed
Hopsken wants to merge 1 commit intobubbuild:mainfrom
Hopsken:fix/gemini-header-routing
Closed

fix: send extra headers only for openrouter provider#87
Hopsken wants to merge 1 commit intobubbuild:mainfrom
Hopsken:fix/gemini-header-routing

Conversation

@Hopsken
Copy link

@Hopsken Hopsken commented Mar 5, 2026

Summary

Fix provider-specific header routing in model calls to avoid passing OpenRouter metadata to incompatible providers (for example Gemini).

What Changed

  • Updated ModelRunner._chat header logic:
    • openrouter:* -> pass extra_headers (HTTP-Referer, X-Title)
    • vertexai:* -> pass http_options.headers (existing behavior)
    • all other providers -> pass no provider-specific headers
  • Updated tests in tests/test_model_runner.py to match the stricter routing behavior.

Why

Gemini rejects unknown config fields like extra_headers, causing runtime validation errors.
Routing headers only where needed prevents cross-provider incompatibilities.

Verification

  • uv run pytest -q tests/test_model_runner.py
  • Result: 12 passed

Impact

  • Fixes Gemini runtime error with BUB_MODEL=gemini:...
  • Keeps OpenRouter attribution headers for OpenRouter
  • Preserves VertexAI-specific header path

@Hopsken
Copy link
Author

Hopsken commented Mar 5, 2026

Just notice that there is a big ongoing refactoring, closing this to avoid conflicts.

@Hopsken Hopsken closed this Mar 5, 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.

1 participant