Add Fireworks AI platform (provider 6)

The 9th registry row, pure Groq pattern: id "fireworks",
FIREWORKS_API_KEY > auth.json "fireworks" scope,
https://api.fireworks.ai/inference/v1 (note /inference/v1) with
KIGI_FIREWORKS_BASE_URL override, OpenAI listing + ChatCompletions +
Passthrough dialect, enrichment-backed metadata (models_dev_id
fireworks-ai) with the tool-calling listing restriction.

Fireworks native ids are deeply slashed (accounts/fireworks/models/glm-5p2);
the e2e pins the full round-trip: the managed key
(fireworks/accounts/fireworks/models/glm-5p2) parses back on the first
slash, and — the 404-risk property — the NATIVE id rides the inference
wire (entry.model and the resolved SamplerConfig.model) while the
fireworks/ prefix stays internal routing only.

Review (models.dev provider.toml + Fireworks docs): row facts confirmed,
registry integrity at 9, counts complete, e2e strong on all axes, zero
defects. One tradeoff logged as debt: restrict_to_enriched drops
fine-tuned/account-scoped deployed models (a headline Fireworks feature)
that can never be in models.dev.
This commit is contained in:
2026-07-21 11:03:50 -04:00
parent 9953a26b8d
commit e373ff8b29
4 changed files with 158 additions and 9 deletions
@@ -596,7 +596,8 @@ mod tests {
"anthropic",
"deepseek",
"groq",
"mistral"
"mistral",
"fireworks"
]
);
assert_eq!(default_id(&built), Some(XAI_API_KEY_METHOD_ID));
@@ -627,7 +628,8 @@ mod tests {
"anthropic",
"deepseek",
"groq",
"mistral"
"mistral",
"fireworks"
]
);
assert_eq!(default_id(&built), Some(CACHED_TOKEN_AUTH_METHOD_ID));
@@ -651,7 +653,8 @@ mod tests {
"anthropic",
"deepseek",
"groq",
"mistral"
"mistral",
"fireworks"
]
);
assert_eq!(default_id(&built), Some(CACHED_TOKEN_AUTH_METHOD_ID));
@@ -678,7 +681,8 @@ mod tests {
"anthropic",
"deepseek",
"groq",
"mistral"
"mistral",
"fireworks"
]
);
assert_eq!(default_id(&built), None);
@@ -1290,6 +1290,111 @@ mod tests {
);
}
/// Fireworks-cycle e2e (Groq pattern): embedding pollution restricted
/// away, Passthrough dialect, and Fireworks' deeply-slashed native ids
/// (`accounts/fireworks/models/…`) round-trip through the managed key
/// (`fireworks/accounts/fireworks/models/…`, first-slash split).
#[tokio::test(flavor = "multi_thread")]
#[serial_test::serial]
async fn fireworks_listing_restricts_maps_dialect_and_keeps_slashed_ids() {
let platform_server = wiremock::MockServer::start().await;
wiremock::Mock::given(wiremock::matchers::method("GET"))
.and(wiremock::matchers::path("/models"))
.and(wiremock::matchers::header("Authorization", "Bearer fw-1"))
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(
serde_json::json!({ "data": [
{ "id": "accounts/fireworks/models/glm-5p2", "object": "model" },
{ "id": "nomic-ai/nomic-embed-text-v1.5", "object": "model" }
]}),
))
.expect(1)
.mount(&platform_server)
.await;
let modelsdev_server = wiremock::MockServer::start().await;
wiremock::Mock::given(wiremock::matchers::method("GET"))
.and(wiremock::matchers::path("/api.json"))
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(
serde_json::json!({ "fireworks-ai": { "models": {
"accounts/fireworks/models/glm-5p2": {
"limit": {"context": 1048575, "output": 65536},
"tool_call": true
},
"nomic-ai/nomic-embed-text-v1.5": { "limit": {"context": 8192} }
}}}),
))
.expect(1)
.mount(&modelsdev_server)
.await;
let cache_dir = tempfile::tempdir().unwrap();
let _base = kigi_test_support::EnvGuard::set(
kigi_models::FIREWORKS_BASE_URL_ENV,
platform_server.uri(),
);
let _mdev = kigi_test_support::EnvGuard::set(
crate::agent::enrichment_fetch::MODELS_DEV_URL_ENV,
format!("{}/api.json", modelsdev_server.uri()),
);
let _mdev_cache = kigi_test_support::EnvGuard::set(
crate::agent::enrichment_fetch::MODELS_DEV_CACHE_DIR_ENV,
cache_dir.path(),
);
let endpoints = crate::agent::config::EndpointsConfig::default();
let keys = crate::agent::models::PlatformApiKeys::test_single(
kigi_models::PlatformId::Fireworks,
"fw-1",
);
let result = tokio::task::spawn_blocking(move || {
fetch_platform_models_blocking(&endpoints, None, &keys)
})
.await
.unwrap()
.expect("fetch must succeed");
assert_eq!(
result
.models
.iter()
.map(|m| m.id.as_deref().unwrap_or_default())
.collect::<Vec<_>>(),
vec!["fireworks/accounts/fireworks/models/glm-5p2"],
"embedding model (enrichment-known, not tool-calling) must be dropped; \
the slashed native id survives in the managed key"
);
let entry = &result.models[0];
assert_eq!(entry.context_window.get(), 1_048_575);
assert_eq!(entry.max_completion_tokens, Some(65_536));
// The NATIVE slashed id rides the inference wire (`model` field);
// the `fireworks/` managed-key prefix is internal routing only. A
// regression here would 404 every Fireworks request.
assert_eq!(
entry.model, "accounts/fireworks/models/glm-5p2",
"wire model must be the native id, not the managed key"
);
// The managed key parses back to (Fireworks, native-slashed-id).
assert_eq!(
kigi_models::parse_managed_model_key(entry.id.as_deref().unwrap()),
Some((
kigi_models::PlatformId::Fireworks,
"accounts/fireworks/models/glm-5p2"
))
);
let model_entry = crate::agent::config::ModelEntry::from_config_entry(entry);
let creds = crate::agent::config::ResolvedCredentials {
api_key: Some("fw-1".into()),
base_url: entry.base_url.clone(),
auth_type: kigi_chat_state::AuthType::ApiKey,
auth_scheme: Default::default(),
};
let cfg = crate::agent::config::sampling_config_for_model(&model_entry, creds, None);
assert_eq!(
cfg.chat_compat,
kigi_sampling_types::ChatCompat::Passthrough
);
assert_eq!(
cfg.model, "accounts/fireworks/models/glm-5p2",
"the sampler wire model is the native slashed id end-to-end"
);
}
#[test]
fn get_env_keys_parses_strings_and_rejects_non_strings() {
use crate::agent::config::EnvKeys;