Add Anthropic platform: wire-served metadata via listing dialect (provider 2)
The 5th registry row: id "anthropic", ANTHROPIC_API_KEY > auth.json "anthropic" scope, api.anthropic.com/v1 with KIGI_ANTHROPIC_BASE_URL override, Messages dialect. Two new spec dimensions most future rows reuse: ListingDialect (Anthropic's /v1/models wants x-api-key + anthropic-version headers, ?limit=1000, and its own response shape) and PlatformKeyHeader (Bearer vs x-api-key across listing/validation/ inference, with auth_scheme stamped onto entries). The 2026 Anthropic listing serves real metadata: the adapter maps max_input_tokens, per-level effort capabilities (low..max as the menu, xhigh/max distinct), thinking/image flags — and enrichment fills only genuine wire gaps (e2e pins wire-1M beating enrichment, and a zero context filled to 200k). Two review-confirmed defects fixed red-green: - Output caps were dropped at three layers, so every sub-128K-output model (64k Haiku, legacy models) would 400 on EVERY request against the sampler's 128K max_tokens default. Wire max_tokens and enrichment limit.output now flow to entry.max_completion_tokens. - An explicit wire effort-decline was indistinguishable from wire silence, letting enrichment inject effort menus pre-4.6 models reject (adaptive thinking 400). The adapter now emits a decline sentinel (support:false) that enrichment respects — proven end to end. Also: the Messages client now sends anthropic-version (previously never sent — real api.anthropic.com rejects such requests; pinned across all three scheme/backend quadrants), key validation builds per-key-header requests, missing listing data fails fast, empty-id ghosts drop with a warning, kimi-import recognizes api.anthropic.com as built-in automatically.
This commit is contained in:
1 parent
23e94939c0
commit
b86722f508
7 files changed
+579
-27
No files matched your search
@@ -19,9 +19,8 @@ pub struct EnrichmentModel {
|
||||
/// Max context window in tokens (`limit.context`).
|
||||
#[serde(default, skip_serializing_if = "is_zero")]
|
||||
pub context: u64,
|
||||
/// Max output tokens (`limit.output`). Not yet consumed by
|
||||
/// [`enrich_wire_model`]; feeds `max_completion_tokens` when provider
|
||||
/// cycles start mapping it.
|
||||
/// Max output tokens (`limit.output`); fills a wire-unserved output cap
|
||||
/// (Anthropic 400s when `max_tokens` exceeds the model's limit).
|
||||
#[serde(default, skip_serializing_if = "is_zero")]
|
||||
pub output: u64,
|
||||
/// Model supports reasoning/thinking.
|
||||
@@ -186,6 +185,9 @@ pub fn enrich_wire_model(wire: &mut crate::WireModel, meta: &EnrichmentModel) {
|
||||
if wire.context_length == 0 && meta.context > 0 {
|
||||
wire.context_length = meta.context;
|
||||
}
|
||||
if wire.max_output_tokens == 0 && meta.output > 0 {
|
||||
wire.max_output_tokens = meta.output;
|
||||
}
|
||||
if meta.reasoning {
|
||||
wire.supports_reasoning = true;
|
||||
}
|
||||
@@ -235,6 +237,7 @@ mod tests {
|
||||
fn enrich_fills_gaps_and_never_overwrites_wire() {
|
||||
let meta = EnrichmentModel {
|
||||
context: 400_000,
|
||||
output: 64_000,
|
||||
reasoning: true,
|
||||
efforts: vec!["low".into(), "high".into()],
|
||||
image_in: true,
|
||||
@@ -246,6 +249,7 @@ mod tests {
|
||||
serde_json::from_value(serde_json::json!({ "id": "gpt-test" })).unwrap();
|
||||
enrich_wire_model(&mut bare, &meta);
|
||||
assert_eq!(bare.context_length, 400_000);
|
||||
assert_eq!(bare.max_output_tokens, 64_000, "output cap filled");
|
||||
assert!(bare.supports_reasoning);
|
||||
assert!(bare.supports_image_in);
|
||||
assert_eq!(bare.display_name.as_deref(), Some("GPT Test"));
|
||||
@@ -258,12 +262,14 @@ mod tests {
|
||||
let mut served: crate::WireModel = serde_json::from_value(serde_json::json!({
|
||||
"id": "gpt-test",
|
||||
"context_length": 123,
|
||||
"max_output_tokens": 77,
|
||||
"display_name": "Wire Name",
|
||||
"think_efforts": { "support": true, "valid_efforts": ["max"] }
|
||||
}))
|
||||
.unwrap();
|
||||
enrich_wire_model(&mut served, &meta);
|
||||
assert_eq!(served.context_length, 123, "wire context wins");
|
||||
assert_eq!(served.max_output_tokens, 77, "wire output cap wins");
|
||||
assert_eq!(served.display_name.as_deref(), Some("Wire Name"));
|
||||
assert_eq!(
|
||||
served.think_efforts.unwrap().valid_efforts,
|
||||
|
||||
Reference in new issue
Block a user