BYOK Custom Endpoint: add "gemini" apiType for Google Generative Language API wire format
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Summary
Custom Endpoint (`vendor: customendpoint`) currently supports three wire formats through `apiType`: `chat-completions`, `responses`, and `messages` (added in #316189).
This asks for a fourth: `gemini`. It's for endpoints that speak Google's `generateContent` REST format. That covers the official API at generativelanguage.googleapis.com, plus any self-hosted gateway or proxy that mirrors it.
This is separate from the existing native `Gemini` BYOK provider (#1310), which is the official-API-key flow. `apiType: gemini` on Custom Endpoint would let people point at any endpoint that speaks the Gemini wire format, the same way they already can for OpenAI-compatible, Responses, or Anthropic Messages endpoints.
## Why `gemini` and not `google` or `googleai`
Google's own docs call this the Gemini API, as distinct from Vertex AI. Vertex AI needs a GCP project and service-account credentials instead of a plain key. Other tools that support both flavors keep the same split for the same reason: mixing them up means someone pastes in an API key and gets asked for GCP credentials instead.
`gemini` also matches this repo's own native BYOK provider, which already uses `vendor: gemini`.
## Scope notes
A few things worth calling out before anyone picks this up:
- The model id lives in the URL path itself (`/v1beta/models/{model}:generateContent`, or `:streamGenerateContent?alt=sse` for streaming) instead of in the request body.
- The auth header is `x-goog-api-key`, which is already in [`customEndpointProvider.ts`'s list of known auth headers](https://github.com/microsoft/vscode/blob/7904fa6dd78c3adcdc31afc10f7ec88d6853d79d/extensions/copilot/src/extension/byok/vscode-node/customEndpointProvider.ts#L222-L228), so the header sanitizer shouldn't need any changes there.
- Request/response conversion could probably reuse `geminiMessageConverter.ts` and `geminiFunctionDeclarationConverter.ts`, which were built for the native Gemini provider and already use `@google/genai` SDK types that mirror the REST JSON schema pretty closely.
## Background
This started as a comment on #325237. That issue bundles a handful of unrelated Custom Endpoint UX requests, so it seemed worth splitting this out on its own.
Happy to work on this if a maintainer can confirm it's not already in progress.
Contributor guide
Assessment
This issue has not been assessed yet.