chore: move rust provider registry into core

This commit is contained in:
Ishaan Jaff 2026-06-24 16:34:48 -07:00
parent 9ba5a1522b
commit 3ecd1202f2
No known key found for this signature in database
4 changed files with 7 additions and 7 deletions

View file

@ -1,7 +1,7 @@
# Adding a provider / route to litellm-rust
- Keep the route contract pure in `crates/core/src/<route>/`: define the typed request/response structs and a provider config trait with no network, env, auth, or logging.
- Add provider identity to `providers/providers.json`: `routing_name` must match Python `LlmProviders.value`; `display_name` is human-facing; `default_api_base` and `api_key_env_var` are optional provider defaults.
- Add provider identity to `crates/core/src/providers/provider_registry.json`: `routing_name` must match Python `LlmProviders.value`; `display_name` is human-facing; `default_api_base` and `api_key_env_var` are optional provider defaults.
- Put provider-specific transforms in `crates/providers/src/<provider>/<route>/transformation.rs`, mirroring the Python provider tree and exposing a `const <PROVIDER>_<ROUTE>_CONFIG`.
- The provider config owns three pure steps: map LiteLLM params, transform the LiteLLM request into the provider request, and transform the provider response back into the LiteLLM response.
- If the provider has a reverse or normalization step, keep it pure and explicit next to the transforms; do not hide reverse mapping inside the HTTP transport.

View file

@ -119,7 +119,7 @@ fn generate_provider_code(providers: &[ProviderMetadataInput]) -> String {
.join("\n");
format!(
r#"// @generated by crates/core/build.rs from litellm-rust/providers/providers.json.
r#"// @generated by crates/core/build.rs from litellm-rust/crates/core/src/providers/provider_registry.json.
// Do not edit this file by hand.
use std::fmt;
@ -204,10 +204,10 @@ mod tests {{
fn registry_provider_values() -> Vec<String> {{
let raw = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../providers/providers.json"
"/src/providers/provider_registry.json"
));
serde_json::from_str::<Vec<RegistryProvider>>(raw)
.expect("providers.json parses")
.expect("provider_registry.json parses")
.into_iter()
.map(|provider| provider.routing_name)
.collect()
@ -309,7 +309,7 @@ mod tests {{
fn main() {
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let providers_path = manifest_dir.join("../../providers/providers.json");
let providers_path = manifest_dir.join("src/providers/provider_registry.json");
println!("cargo:rerun-if-changed={}", providers_path.display());
println!(
"cargo:rerun-if-changed={}",

View file

@ -1,13 +1,13 @@
# Rust Provider Registry
`providers.json` is the source of truth for provider identity in `litellm-rust`.
`provider_registry.json` is the source of truth for provider identity in `litellm-rust`.
`crates/core/build.rs` reads it at compile time and generates the typed
`LlmProvider` enum plus static provider metadata. Runtime code does not parse
this JSON.
To add a provider:
- Add a `providers.json` entry with `routing_name` matching Python
- Add a `provider_registry.json` entry with `routing_name` matching Python
`LlmProviders.value` in `litellm/types/utils.py`.
- Set `display_name` to the human-readable provider name for docs/errors.
- Set `default_api_base` to a stable provider-level default base URL, or `null`