From 3ecd1202f27d65bcc0366b345d77ac58a1ca935c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 24 Jun 2026 16:34:48 -0700 Subject: [PATCH] chore: move rust provider registry into core --- litellm-rust/ADDING_A_PROVIDER.md | 2 +- litellm-rust/crates/core/build.rs | 8 ++++---- litellm-rust/{ => crates/core/src}/providers/README.md | 4 ++-- .../core/src/providers/provider_registry.json} | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename litellm-rust/{ => crates/core/src}/providers/README.md (84%) rename litellm-rust/{providers/providers.json => crates/core/src/providers/provider_registry.json} (100%) diff --git a/litellm-rust/ADDING_A_PROVIDER.md b/litellm-rust/ADDING_A_PROVIDER.md index ac454727c8a..48f8f75dceb 100644 --- a/litellm-rust/ADDING_A_PROVIDER.md +++ b/litellm-rust/ADDING_A_PROVIDER.md @@ -1,7 +1,7 @@ # Adding a provider / route to litellm-rust - Keep the route contract pure in `crates/core/src//`: 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///transformation.rs`, mirroring the Python provider tree and exposing a `const __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. diff --git a/litellm-rust/crates/core/build.rs b/litellm-rust/crates/core/build.rs index e31152c2035..dfc415345a1 100644 --- a/litellm-rust/crates/core/build.rs +++ b/litellm-rust/crates/core/build.rs @@ -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 {{ let raw = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), - "/../../providers/providers.json" + "/src/providers/provider_registry.json" )); serde_json::from_str::>(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={}", diff --git a/litellm-rust/providers/README.md b/litellm-rust/crates/core/src/providers/README.md similarity index 84% rename from litellm-rust/providers/README.md rename to litellm-rust/crates/core/src/providers/README.md index 0191656373e..c8e2b8a2526 100644 --- a/litellm-rust/providers/README.md +++ b/litellm-rust/crates/core/src/providers/README.md @@ -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` diff --git a/litellm-rust/providers/providers.json b/litellm-rust/crates/core/src/providers/provider_registry.json similarity index 100% rename from litellm-rust/providers/providers.json rename to litellm-rust/crates/core/src/providers/provider_registry.json