#34872 [Bug]: Gemini context caching with custom api_base uses invalid cache URL and auth header
## Check for existing issues
- [x] I searched the existing issues and did not find a duplicate covering both the model-scoped `cachedContents` URL and malformed authentication header.
Related:
- #23846 - #23928
## What happened?
Gemini explicit context caching fails when the SDK uses a custom `api_base` implementing the standard Gemini REST API.
When a prompt contains an Anthropic-style `cache_control` marker and exceeds Gemini's minimum cache size, LiteLLM makes a secondary request to the named-cache API. For a custom Gemini base URL, LiteLLM currently:
1. sends the request to: ```text {api_base}/models/{model}:cachedContents ``` 2. converts the Gemini API-key header dictionary into a malformed Bearer value: ```text Authorization: Bearer {'x-goog-api-key': '<redacted>'} ```
The standard Gemini named-cache API uses the collection endpoint:
```text {api_base}/cachedContents ```
The model belongs in the create request body, for example:
```json {"model": "models/gemini-2.5-flash"} ```
This affects standards-compatible Gemini proxies such as Bifrost. The normal `generateContent` request succeeds through the same custom `api_base`; only the explicit context-…