Repository navigation
feat(proxy): add POST /v1/callbacks/logs to replay logging payloads through callbacks #31134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
40 commits merged into
litellm_internal_staging
from
litellm_proxy_callbacks_logs_ingest
Jun 24, 2026
Merged
Changes from 33 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
37ac6ce
feat(proxy): add logging_endpoints package init
ishaan-jaff 8db98fe
feat(proxy): add POST /v1/callbacks/logs to replay logging payloads t…
ishaan-jaff ed3c448
feat(proxy): register callback_logs_router
ishaan-jaff 4c78a20
test(proxy): add logging_endpoints test package init
ishaan-jaff 63790ca
test(proxy): cover /v1/callbacks/logs replay, admin guard, and partia…
ishaan-jaff 64c0a12
refactor(proxy): move callback-logs request/response models to litell…
ishaan-jaff 86f85da
refactor(proxy): wrap callback-logs replay in CallbackLogsReplayer cl…
ishaan-jaff 0727631
test(proxy): update callback-logs tests for class-based replayer and …
ishaan-jaff 6bb369e
fix(proxy): cover /v1/callbacks/ in backend component allowlist
ishaan-jaff e791b2f
refactor(proxy): use builtin dict/list generics in callback-logs endp…
ishaan-jaff 834af9f
refactor(proxy): use builtin dict/list generics in callback-logs types
ishaan-jaff 123f138
chore(ui): regenerate schema.d.ts for /v1/callbacks/logs
ishaan-jaff e18342e
fix(proxy): force stream=False when replaying callback logs
ishaanj-berri 56ef43a
feat(litellm-rust): CustomLogger callback layer posting to /v1/callba…
ishaanj-berri 2af8b5e
feat(litellm-rust): RealTimeStreaming per-session log collector
ishaanj-berri f62b35e
feat(litellm-rust): wire realtime logging into the splice (lock-free …
ishaanj-berri 5130ad7
docs(litellm-rust): ai-gateway realtime logging architecture
ishaanj-berri a0fe2c5
docs(litellm-rust): document request-log egress to the LiteLLM contro…
ishaanj-berri acc8ffa
feat(litellm-rust): make log-egress tunables env-overridable
ishaanj-berri f79a5ed
docs(litellm-rust): document log-egress tuning env vars
ishaanj-berri b66dc84
docs(litellm-rust): require constants in a crate-level constants.rs
ishaanj-berri e58084c
refactor(litellm-rust): move ai-gateway constants into constants.rs
ishaanj-berri 0cc1896
ci: run logging_endpoints tests in the proxy-infra coverage shard
ishaanj-berri 5072e32
fix(litellm-rust): hash the master key before logging — never send th…
ishaanj-berri ba71c73
fix(litellm-rust): observe realtime logging on upstream events only
ishaanj-berri 17c5cb6
feat(proxy): bound callback-logs batch + return per-record failures
ishaanj-berri 4fcc554
chore(ui): regenerate schema.d.ts for CallbackLogFailure / failures f…
ishaanj-berri 7efe8c0
Merge remote-tracking branch 'upstream/litellm_internal_staging' into…
ishaanj-berri 13e12f1
fix(constants): make MAX_CALLBACK_LOG_RECORDS a plain constant
ishaanj-berri 2f122a9
docs(litellm-rust): trim ai-gateway ARCHITECTURE.md to one diagram + …
ishaanj-berri 10ce828
docs(litellm-rust): tighten the README request-logging section
ishaanj-berri 9dbc013
docs(litellm-rust): ARCHITECTURE.md is just the diagram (gateway = in…
ishaanj-berri d8733be
docs(litellm-rust): drop em-dashes from the request-logging section
ishaanj-berri e4f9066
Merge remote-tracking branch 'upstream/litellm_internal_staging' into…
ishaanj-berri 7f9f4fd
chore: stop tracking stray .coverage artifact and gitignore it
ishaanj-berri 616ca9f
feat(proxy): namespace rust-gateway routes under /v1/rust_control_plane
ishaanj-berri abd3db5
refactor(litellm-rust): POST logs to /v1/rust_control_plane/logs
ishaanj-berri 9cee1c1
docs(litellm-rust): update README to /v1/rust_control_plane/logs
ishaanj-berri 1e2a127
chore(ui): regenerate schema.d.ts for /v1/rust_control_plane/logs
ishaanj-berri a76a47d
refactor(litellm-rust): collapse env_positive_{usize,u64} into one ge…
ishaanj-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # ai-gateway architecture | ||
|
|
||
| The Rust ai-gateway does LLM inference (realtime WebSocket). Spend tracking is an | ||
| API callback: it POSTs each finished session to the LiteLLM proxy, which records | ||
| spend and runs the usual callbacks. | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| C[client] <--> G[Rust ai-gateway<br/>LLM inference] | ||
| G <--> O[OpenAI realtime] | ||
| G -. spend tracking callback .-> P[litellm proxy] | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| //! Crate-level constants for the ai-gateway. | ||
| //! | ||
| //! Per `litellm-rust/CLAUDE.md`, magic numbers and fixed strings live here | ||
| //! (the Rust mirror of Python's `litellm/constants.py`), not inline in feature | ||
| //! modules. Env-overridable tunables keep their `DEFAULT_*` value here; the env | ||
| //! read + fallback happens at the host/config layer. | ||
|
|
||
| /// Default LiteLLM control-plane base URL for request-log egress when | ||
| /// `LITELLM_PROXY_BASE_URL` is unset. | ||
| pub(crate) const DEFAULT_PROXY_BASE_URL: &str = "http://localhost:4000"; | ||
|
|
||
| /// The logs ingest path appended to the proxy base. Not a tunable — it is the | ||
| /// proxy's API contract. | ||
| pub(crate) const CALLBACK_LOGS_PATH: &str = "/v1/callbacks/logs"; | ||
|
|
||
| /// Default bounded channel depth for the log-egress worker. | ||
| /// Override: `LITELLM_LOG_CHANNEL_CAPACITY`. | ||
| pub(crate) const DEFAULT_CHANNEL_CAPACITY: usize = 4096; | ||
|
|
||
| /// Default max records POSTed per request to the control plane. | ||
| /// Override: `LITELLM_LOG_BATCH_SIZE`. | ||
| pub(crate) const DEFAULT_MAX_BATCH_SIZE: usize = 256; | ||
|
|
||
| /// Default partial-batch flush cadence, in ms. | ||
| /// Override: `LITELLM_LOG_FLUSH_INTERVAL_MS`. | ||
| pub(crate) const DEFAULT_FLUSH_INTERVAL_MS: u64 = 500; | ||
|
|
||
| /// Provider attributed to realtime sessions in the logging payload. | ||
| pub(crate) const DEFAULT_PROVIDER: &str = "openai"; |
24 changes: 24 additions & 0 deletions
24
litellm-rust/crates/ai-gateway/src/integrations/custom_logger.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //! The `CustomLogger` trait — the Rust mirror of Python | ||
| //! `litellm/integrations/custom_logger.py::CustomLogger`. | ||
| //! | ||
| //! Synchronous (no `async_trait`): callbacks are O(1) enqueue-and-return so the | ||
| //! realtime splice never blocks on a logger. Default bodies are no-ops so a | ||
| //! logger can implement only the events it cares about. | ||
|
|
||
| use crate::integrations::types::{LogError, LoggingError, StandardLoggingPayload}; | ||
|
|
||
| pub trait CustomLogger: Send + Sync { | ||
| /// Record a successful call. Default: no-op. | ||
| fn log_success_event(&self, _payload: &StandardLoggingPayload) -> Result<(), LogError> { | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Record a failed call. Default: no-op. | ||
| fn log_failure_event( | ||
| &self, | ||
| _payload: &StandardLoggingPayload, | ||
| _error: &LoggingError, | ||
| ) -> Result<(), LogError> { | ||
| Ok(()) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.