Merge PR #420: fix: respect OPENAI_BASE_URL when resolving API key priority
Authored by manuelschipper. Adds GLM-4.7 and GLM-5 context lengths (202752) to model_metadata.py. The key priority fix (prefer OPENAI_API_KEY for non-OpenRouter endpoints) was already applied in PR #295; merged the Z.ai mention into the comment.
This commit is contained in:
commit
3c6c11b7c9
2 changed files with 5 additions and 2 deletions
|
|
@ -49,6 +49,8 @@ DEFAULT_CONTEXT_LENGTHS = {
|
||||||
"meta-llama/llama-3.3-70b-instruct": 131072,
|
"meta-llama/llama-3.3-70b-instruct": 131072,
|
||||||
"deepseek/deepseek-chat-v3": 65536,
|
"deepseek/deepseek-chat-v3": 65536,
|
||||||
"qwen/qwen-2.5-72b-instruct": 32768,
|
"qwen/qwen-2.5-72b-instruct": 32768,
|
||||||
|
"glm-4.7": 202752,
|
||||||
|
"glm-5": 202752,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,9 @@ def _resolve_openrouter_runtime(
|
||||||
|
|
||||||
# Choose API key based on whether the resolved base_url targets OpenRouter.
|
# Choose API key based on whether the resolved base_url targets OpenRouter.
|
||||||
# When hitting OpenRouter, prefer OPENROUTER_API_KEY (issue #289).
|
# When hitting OpenRouter, prefer OPENROUTER_API_KEY (issue #289).
|
||||||
# When hitting a custom endpoint, prefer OPENAI_API_KEY so the OpenRouter
|
# When hitting a custom endpoint (e.g. Z.ai, local LLM), prefer
|
||||||
# key doesn't leak to an unrelated provider (issue #560).
|
# OPENAI_API_KEY so the OpenRouter key doesn't leak to an unrelated
|
||||||
|
# provider (issues #420, #560).
|
||||||
_is_openrouter_url = "openrouter.ai" in base_url
|
_is_openrouter_url = "openrouter.ai" in base_url
|
||||||
if _is_openrouter_url:
|
if _is_openrouter_url:
|
||||||
api_key = (
|
api_key = (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue