Add OpenAI platform: live model fetching with enrichment (provider 1)

The 4th registry row: id "openai", OPENAI_API_KEY env > auth.json
"openai" scope (login picker/paste/validation all registry-generic —
zero TUI changes needed, pinned by the picker test), base
https://api.openai.com/v1 with KIGI_OPENAI_BASE_URL override, Responses
dialect via the new PlatformWireApi spec field, enrichment-backed
metadata (wire_serves_metadata=false).

OpenAI's GET /v1/models returns bare ids and is polluted with
tts/whisper/embeddings entries: the listing is restricted to
enrichment-known TOOL-CALLING models (review caught that membership
alone admitted models.dev-known embeddings models, which would 400 on
every agentic request; dropped ids are debug-logged for launch-day
diagnosability). Context windows, effort menus, display names, and
thinking capability come from the enrichment pipeline — wiremock e2e
pins the full contract: polluted live listing + models.dev →
one Responses-backed chat model with a 400k documented context window.

Responses max-effort wiring (closes the P0c-1 debt): canonical effort
rides a CreateResponseWrapper sidecar and patch_reasoning_effort writes
it onto the serialized body at both send sites (all seven levels pinned,
xhigh/max distinct, summary preserved); normalize_effort_echo drops
echoes async-openai's typed enum cannot represent at both the non-stream
and SSE parse seams; the dead typed to_responses_api converter is
deleted. Kimi/moonshot stay byte-identical (ChatCompletions untouched,
wire_api maps to the same default; kimi wire tests green).

kimi-import now recognizes ANY registry platform host as built-in
(was hardcoded moonshot), covering openai and future rows.
This commit is contained in:
2026-07-21 05:04:55 -04:00
parent fdf9b956f5
commit 23e94939c0
10 changed files with 436 additions and 58 deletions
+12 -8
View File
@@ -160,18 +160,22 @@ struct KimiProviderToml {
}
/// Built-in kigi platform a kimi provider duplicates, if any: provider type
/// `kimi` is the Kimi Code subscription channel; the two Moonshot open
/// platforms are recognized by their fixed production hosts (the same hosts
/// `kigi_models::PlatformId::base_url` compiles in).
/// `kimi` is the Kimi Code subscription channel; API-key platforms are
/// recognized by their production hosts (the same hosts
/// `kigi_models::PlatformId::base_url` compiles in — moonshot, openai, and
/// every future registry row automatically).
fn builtin_platform(provider: &KimiProviderToml) -> Option<PlatformId> {
if provider.provider_type == "kimi" {
return Some(PlatformId::KimiCode);
}
match url_host(&provider.base_url) {
Some("api.moonshot.cn") => Some(PlatformId::MoonshotCn),
Some("api.moonshot.ai") => Some(PlatformId::MoonshotAi),
_ => None,
}
let host = url_host(&provider.base_url)?;
PlatformId::ALL.into_iter().find(|platform| {
if platform.uses_oauth() {
return false;
}
let base = platform.base_url();
url_host(&base) == Some(host)
})
}
/// Host component of an http(s) URL. `None` for other schemes.