litellm-rust/crates/CODING_STANDARDS/PROVIDER_CODING_STANDARDS.md
Rules for adding or changing an LLM provider/route in litellm-rust. OCR (MISTRAL_OCR_CONFIG) is the reference; messages (ANTHROPIC_MESSAGES_CONFIG) is the next port.
get_custom_llm_provider (core/src/routing_utils/provider.rs). Nothing downstream may branch on a raw model string.prepare.rs, and passed down as typed fields. Don't re-resolve or re-parse it in transforms or handlers.transform_request + transform_response (+ complete_url, supported_params), living in core/src/<route>/transformation.rs (e.g. AnthropicMessagesProviderConfig, mirroring OcrProviderConfig).const <PROVIDER>_<ROUTE>_CONFIG in core/src/providers/<provider>/<route>/transformation.rs, mirroring the Python provider tree.core = pure transforms/types (no network, env, secrets, auth, logging, global mutable state); ai-gateway = all I/O, auth headers, HTTP/SSE, lifecycle hooks; python-bridge = thin PyO3 adapter.core/src/providers/<provider>/<route>/; a route is a module, never a new crate.<route>() -> prepare_* -> CallLifecycle::run_request, which owns the pre_call -> during_call -> provider call -> success/failure order and phase timing. Handlers validate and delegate; no business logic in them.constants.rs, never inline. Env reads happen only at the host/config layer, with the DEFAULT_* fallback defined in constants.rs.serde_json::Value / String / Vec<String> as a transform input or output. Parse wire bytes into typed structs/enums at the host edge; a type discriminator is a typed field, not a raw string.CoreError, don't panic. No unwrap/expect/panic! on user or provider input.collect), prefer immutable bindings and owned typed structs over seeding-and-mutating.null for parity, keep it and pin it with a test.*_match_python fixture parity.litellm/main.py. A route's provider dispatch lives in a thin dispatch class under litellm/llms/<provider>/<route>/ that calls the Rust bridge; main.py only instantiates it and calls its sync/async method.use_litellm_rust); never introduce a per-route env flag such as LITELLM_USE_RUST_<ROUTE>.cd litellm-rust
cargo fmt --check
cargo clippy -p litellm-ai-gateway --all-targets --features server -- -D warnings
cargo clippy -p litellm-core -p litellm-python-bridge --all-targets -- -D warnings
cargo test --workspace