fix: Update Kimi Coding API endpoint and User-Agent
This commit is contained in:
@@ -845,7 +845,7 @@ def _resolve_api_key_provider() -> Tuple[Optional[OpenAI], Optional[str]]:
|
|||||||
return GeminiNativeClient(api_key=api_key, base_url=base_url), model
|
return GeminiNativeClient(api_key=api_key, base_url=base_url), model
|
||||||
extra = {}
|
extra = {}
|
||||||
if base_url_host_matches(base_url, "api.kimi.com"):
|
if base_url_host_matches(base_url, "api.kimi.com"):
|
||||||
extra["default_headers"] = {"User-Agent": "KimiCLI/1.30.0"}
|
extra["default_headers"] = {"User-Agent": "claude-code/0.1.0"}
|
||||||
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
||||||
from hermes_cli.models import copilot_default_headers
|
from hermes_cli.models import copilot_default_headers
|
||||||
|
|
||||||
@@ -871,7 +871,7 @@ def _resolve_api_key_provider() -> Tuple[Optional[OpenAI], Optional[str]]:
|
|||||||
return GeminiNativeClient(api_key=api_key, base_url=base_url), model
|
return GeminiNativeClient(api_key=api_key, base_url=base_url), model
|
||||||
extra = {}
|
extra = {}
|
||||||
if base_url_host_matches(base_url, "api.kimi.com"):
|
if base_url_host_matches(base_url, "api.kimi.com"):
|
||||||
extra["default_headers"] = {"User-Agent": "KimiCLI/1.30.0"}
|
extra["default_headers"] = {"User-Agent": "claude-code/0.1.0"}
|
||||||
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
||||||
from hermes_cli.models import copilot_default_headers
|
from hermes_cli.models import copilot_default_headers
|
||||||
|
|
||||||
@@ -1487,7 +1487,7 @@ def _to_async_client(sync_client, model: str):
|
|||||||
|
|
||||||
async_kwargs["default_headers"] = copilot_default_headers()
|
async_kwargs["default_headers"] = copilot_default_headers()
|
||||||
elif base_url_host_matches(sync_base_url, "api.kimi.com"):
|
elif base_url_host_matches(sync_base_url, "api.kimi.com"):
|
||||||
async_kwargs["default_headers"] = {"User-Agent": "KimiCLI/1.30.0"}
|
async_kwargs["default_headers"] = {"User-Agent": "claude-code/0.1.0"}
|
||||||
return AsyncOpenAI(**async_kwargs), model
|
return AsyncOpenAI(**async_kwargs), model
|
||||||
|
|
||||||
|
|
||||||
@@ -1674,7 +1674,7 @@ def resolve_provider_client(
|
|||||||
)
|
)
|
||||||
extra = {}
|
extra = {}
|
||||||
if base_url_host_matches(custom_base, "api.kimi.com"):
|
if base_url_host_matches(custom_base, "api.kimi.com"):
|
||||||
extra["default_headers"] = {"User-Agent": "KimiCLI/1.30.0"}
|
extra["default_headers"] = {"User-Agent": "claude-code/0.1.0"}
|
||||||
elif base_url_host_matches(custom_base, "api.githubcopilot.com"):
|
elif base_url_host_matches(custom_base, "api.githubcopilot.com"):
|
||||||
from hermes_cli.models import copilot_default_headers
|
from hermes_cli.models import copilot_default_headers
|
||||||
extra["default_headers"] = copilot_default_headers()
|
extra["default_headers"] = copilot_default_headers()
|
||||||
@@ -1781,7 +1781,7 @@ def resolve_provider_client(
|
|||||||
# Provider-specific headers
|
# Provider-specific headers
|
||||||
headers = {}
|
headers = {}
|
||||||
if base_url_host_matches(base_url, "api.kimi.com"):
|
if base_url_host_matches(base_url, "api.kimi.com"):
|
||||||
headers["User-Agent"] = "KimiCLI/1.30.0"
|
headers["User-Agent"] = "claude-code/0.1.0"
|
||||||
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
||||||
from hermes_cli.models import copilot_default_headers
|
from hermes_cli.models import copilot_default_headers
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ PROVIDER_REGISTRY: Dict[str, ProviderConfig] = {
|
|||||||
id="kimi-coding",
|
id="kimi-coding",
|
||||||
name="Kimi / Moonshot",
|
name="Kimi / Moonshot",
|
||||||
auth_type="api_key",
|
auth_type="api_key",
|
||||||
inference_base_url="https://api.moonshot.ai/v1",
|
inference_base_url="https://api.kimi.com/coding",
|
||||||
api_key_env_vars=("KIMI_API_KEY", "KIMI_CODING_API_KEY"),
|
api_key_env_vars=("KIMI_API_KEY", "KIMI_CODING_API_KEY"),
|
||||||
base_url_env_var="KIMI_BASE_URL",
|
base_url_env_var="KIMI_BASE_URL",
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user