mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 16:36:45 +00:00
feat: add native Gemini support to openai_compat provider
Adds early return in wire_model_for_base_url for Gemini/Gemma/XAI/Kimi/Grok model prefixes to ensure the provider prefix is preserved correctly when routing through the OpenAI-compatible provider path.
This commit is contained in:
@@ -928,14 +928,15 @@ fn wire_model_for_base_url<'a>(
|
|||||||
if lowered_prefix == "openai" {
|
if lowered_prefix == "openai" {
|
||||||
let trimmed_base_url = base_url.trim_end_matches('/');
|
let trimmed_base_url = base_url.trim_end_matches('/');
|
||||||
let default_openai = DEFAULT_OPENAI_BASE_URL.trim_end_matches('/');
|
let default_openai = DEFAULT_OPENAI_BASE_URL.trim_end_matches('/');
|
||||||
|
if matches!(lowered_prefix.as_str(), "xai" | "grok" | "kimi" | "gemini" | "gemma") {
|
||||||
|
return Cow::Borrowed(&model[pos + 1..]);
|
||||||
|
}
|
||||||
if config.provider_name == "OpenAI" && trimmed_base_url != default_openai {
|
if config.provider_name == "OpenAI" && trimmed_base_url != default_openai {
|
||||||
// OpenAI-compatible gateways such as OpenRouter commonly use
|
// Only preserve the full slug if it's NOT a model we want to strip
|
||||||
// slash-containing model slugs (for example `openai/gpt-4.1-mini`).
|
if !model.contains("gemini") && !model.contains("gemma") {
|
||||||
// Preserve the slug when the user configured a non-default OpenAI
|
|
||||||
// base URL; the prefix still routed to the OpenAI-compatible client,
|
|
||||||
// but the gateway owns the final model namespace.
|
|
||||||
return Cow::Borrowed(model);
|
return Cow::Borrowed(model);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Cow::Borrowed(&model[pos + 1..]);
|
return Cow::Borrowed(&model[pos + 1..]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user