Should LiteLLM store prompts and responses in request logs?
By default, LiteLLM tracks success and error logs without storing request and response content. Prompt and response bodies are kept only when store_prompts_in_spend_logs is enabled, and that setting can be changed from the admin UI without a restart or set in config. For a security or compliance team asking what the gateway keeps about each AI call, the answer starts with metadata: who called, which key and team, which model, token counts, spend, latency and error status. Bodies are a separate decision, and it should be made on purpose rather than inherited from a default.
Teams usually need bodies when an investigation depends on what was actually said or returned, such as a suspected prompt injection, a data exposure report, a disputed model output, or a misuse case that metadata alone cannot explain. Metadata is usually enough for capacity planning, chargeback, budget enforcement, error triage and most access reviews. Before enabling content storage, confirm with legal, privacy and the data owners which prompts can contain personal or regulated data, who will be allowed to read stored bodies, and how long they must be kept. Ask whether the business needs bodies for every team or only for specific keys and models, because that answer drives the scope of the change.
Storing bodies also changes the rest of the design. Spend logs grow with prompt size, so the database and retention plan must account for the extra volume. Masking must be decided before content reaches any logging callback, which is covered in the next section. Verify the setting in a non-production environment by sending a known test prompt, confirming what lands in the log store, and checking who can view it in the admin UI. Record the decision and the test result so auditors can see why content is or is not kept.
What each logging mode keeps
Metadata only is the default. LiteLLM tracks success and error logs without storing request and response content, so the UI shows the call record rather than the conversation. Each entry carries the facts needed to answer operational and financial questions: which key or team made the call, which model and provider handled it, the timing, the token counts, the status and the spend recorded for it.
- Investigations: you can see that a key called a model at a given time and failed, but not what the prompt said, so incident work starts from the metadata and may need another source.
- Cost reconciliation: token counts and model names are the inputs for matching spend to provider invoices, which is usually the main reason teams keep logs at all.
- Privacy review: the store holds no prompt text, which narrows the personal data review to identifiers such as key names, user IDs and metadata you attach yourself.
- Storage growth: rows stay small, so database size grows slowly compared with body storage.
- Limits: if a regulator or internal team asks what a user actually sent, metadata alone cannot answer.
Before relying on this mode, confirm with your own test traffic which fields your LiteLLM version writes to the log store and whether your metadata tags contain anything sensitive.
Enabling store_prompts_in_spend_logs makes LiteLLM keep the request and response content alongside the usual log record. You can turn it on from the admin UI without a restart or in the proxy config. The result is a searchable record of what was sent and returned, which is the main reason security and quality teams ask for it.
- Investigations: analysts can reconstruct a conversation, find the prompt behind an unusual call or confirm what data left the gateway.
- Cost reconciliation: bodies add volume but not new billing facts, so finance still relies on token counts and spend fields.
- Privacy review: prompts can contain personal data, credentials and confidential content, so the stored table becomes a data store with its own retention, access and deletion duties.
- Storage growth: the database grows with prompt and response size, not call count, so long context windows can change capacity planning quickly.
- Access: anyone who can read the logs can read the bodies, so restrict who holds the admin view and the database.
Before enabling this mode, decide the retention period, who may query bodies, and whether you need masking first, then test the database size with realistic traffic.
A mixed arrangement keeps bodies for some teams or workloads and metadata for others. Teams that handle regulated or personal data may need metadata only, while a team building a prompt evaluation set may need full bodies. Per-team logging opt-outs are an Enterprise capability in the LiteLLM feature set, so confirm which edition and version provide them before designing around them.
- Scope: define which teams, keys or models may store bodies, and record that decision with the owner who approved it.
- Investigations: analysts need to know which team's logs contain bodies, otherwise a search returns partial evidence without warning.
- Cost reconciliation: the same metadata fields apply to every team, so finance reports stay consistent across modes.
- Privacy review: each body-storing team creates its own data flow to document, which increases the review scope.
- Drift: settings change over time, so review the per-team configuration on a schedule and after each upgrade.
Before committing to this model, confirm the exact control names, the scope at which they apply and how changes are audited in your release.
Configuration options for prompt and response storage
This table compares the four ways to handle prompt and response content in LiteLLM logs, from the metadata-only default to masking content before any logging integration receives it. Read each row for the situation it fits and the trade-off it carries, then pick the least content-heavy option that still meets your investigation and audit needs.
| Option | When it fits | Main trade-off |
|---|---|---|
| Keep metadata only (default) | Teams that need success and error logs, costs and latency, but no request or response text in the gateway | Investigations of what a user actually sent or received will lack the content itself |
| Enable store_prompts_in_spend_logs from the admin UI | Quick enablement for a named investigation or pilot, changed without restarting the proxy | Content is stored from that point on, so a UI change can silently widen what is kept; confirm who can change it |
| Enable store_prompts_in_spend_logs in config | Standard environments where the setting is version-controlled and reviewed like other gateway configuration | Every stored prompt and response adds database growth, so retention and storage sizing must be planned before enabling |
| Mask content with a custom async_logging_hook | Workloads where logs must be useful for debugging but personal or confidential text must not reach logging integrations | You own the masking logic, so its coverage, testing and maintenance fall to your team |
How to enable and verify prompt storage in LiteLLM
This sequence turns on body storage for one deliberately chosen scope, proves that prompts and responses appear in the logs, and confirms that other keys still log metadata only. It also gives you a tested path back to the default.
Confirm the database is PostgreSQL
Before changing anything, the platform owner checks that the proxy is connected to PostgreSQL, the primary supported database named in LiteLLM's production guide, and that the request logs the UI shows are being written there. Spend logs are the store this setting writes into, so a gateway without a working database cannot keep bodies at all. Check the database connection in the proxy configuration and confirm that the Logs page in the admin UI loads recent success entries. The step is done when you can see a recent request listed with its model, key and token counts.
Decide the scope and owner of the setting
Decide which team or key will store bodies, who approves that decision, and who is responsible for the stored data. Storing prompts is a data handling choice, so record the team, the business reason, the retention period your policy requires and the person who answers for deletion requests. Prefer a dedicated test key or one team over the whole gateway, because the setting controls logging for the proxy as a whole, and you should confirm with the vendor documentation how the flag interacts with per-team logging controls in your version. The step is done when the decision is written down and the approver has signed off.
Enable store_prompts_in_spend_logs
Turn on store_prompts_in_spend_logs from the admin UI or in the proxy configuration file. The UI option applies without a restart, while the config option requires the proxy to reload its settings, so use the path your team manages change control for. Record who made the change, when, and through which path, because the setting is the single control that moves the gateway from metadata to content. The step is done when the setting reads as enabled in the place you changed it and the change is recorded in your change log.
Send a test request and confirm the body appears
Send one test request through the scoped key using a prompt with a clearly fake marker string, such as a made-up code word, so you can search for it. Open the matching entry in the admin UI logs and confirm that the prompt and the response text are visible. Search the log store for the marker to confirm it is indexed where you expect. This is a test of behavior, so use synthetic content only and never a real customer record. The step is done when the marker string is visible in the stored request and response for the test key.
Confirm metadata-only behavior on a second key
Create or pick a second virtual key that belongs to a different team, send a request with a different marker string, and open its log entry. If the setting is applied gateway wide, the body will also appear, which is an important finding that means your scope plan needs a per-team control before go live. If the body does not appear for the second key, you have confirmed the expected scope. Record the result for each key, since this check is the evidence an assessor or security reviewer will ask for. The step is done when you have a written result for both keys showing where bodies are stored.
Check storage growth and access
Measure how fast the spend logs table grows during the test window and confirm who can open the Logs page and export its contents. Bodies make rows much larger than metadata, so look at database size before and after a set of test requests and compare the result with the storage you planned. Confirm that only the roles you approved can view body content in the UI and API. The step is done when you have a size comparison and a list of roles with access, and both match the decision from the scope step.
Roll back to metadata only
Prepare the rollback before you need it. Turn store_prompts_in_spend_logs off using the same path you used to enable it, send a request from the test key, and confirm that the new entry shows metadata without the body. Decide with the owner what happens to bodies already stored, whether they are deleted, kept under a legal hold or left in place, and record that decision. Rehearse this in a test environment first, and confirm with your database team how stored rows are removed. The step is done when a post-rollback request shows no body and the cleanup decision is documented.
How prompt bodies change storage growth
Storing request and response bodies changes the database more than any other logging decision. Metadata-only logging writes a small row per call, while enabling store_prompts_in_spend_logs adds the full prompt and completion text to the same spend log table. Because prompts carry system instructions, conversation history and retrieved documents, a single row can be far larger than its metadata equivalent. Plan the database capacity, the retention window and the cleanup job before you turn the setting on, not after the table has grown.
Growth depends on more than the user's question. Long conversations resend earlier turns on every call, so the stored prompt for later messages repeats much of the history. Tool calls and tool output add further volume, and agent workflows that read files, search documents or query internal systems can return large payloads that LiteLLM records as part of the exchange. Streaming responses, multiple retries and fallbacks may also create additional log entries, so count rows per user action as well as per API call. Confirm with your LiteLLM version how each of these appears in the spend log table.
Run a pilot with the setting enabled on a representative team before rolling it out. Measure the average and largest row size for each caller, the rows written per user session, and the table and index size per day at your expected traffic. Test how long the cleanup job takes to delete a day of data while the gateway is serving requests, and confirm that PostgreSQL vacuum and backup windows still fit. Ask your database team for the storage growth rate they can support, and set an alert on table size before the pilot ends, so the production retention period is based on your measurements rather than estimates.
How a request flows through masking and storage
The diagram starts at the client request reaching the LiteLLM proxy. Request and response content only passes through the optional async_logging_hook masking step if you have configured one, and only reaches PostgreSQL spend logs when store_prompts_in_spend_logs is enabled. Logging callbacks receive whatever the proxy emits at that point, so check that masking runs before the callback boundary, not after it.
Masking sits between the proxy and both storage and external logging callbacks.
Masking content before it reaches logging callbacks
If LiteLLM stores prompt and response bodies, masking decides what leaves the gateway in plain text. The cards below cover how the custom async_logging_hook works, what to redact, how to test it, and where masking can fail. Each control reduces exposure, but none removes the need to verify the output against your own sample data.
Custom async_logging_hook
LiteLLM supports masking logged requests and responses before they reach logging integrations through a custom async_logging_hook. The hook runs in your own code, so the masking logic lives with your team and changes with your policy. Confirm the hook signature and where it is registered against the version you run, since the scrub data docs define the contract you must follow.
Scrub data docsRedacting personal data and secrets
Decide which fields the hook must redact before any callback sees them: personal identifiers in message text, API keys or tokens pasted into prompts, and account numbers or record IDs. Redact secrets first, because a credential in a logged prompt is exposed even if the rest of the record is protected. Keep a written list of patterns and the owner who approves changes.
Testing the hook against sample prompts
Run the hook against a fixed set of sample prompts that include known personal data and secrets, then inspect what each logging integration receives. Check the database row, any callback target and any export file, not only the hook's return value. Repeat the test after every hook change or LiteLLM upgrade, and keep the results as evidence for your reviewers.
Tool calls and attachments
Masking written for plain message text can miss content carried in tool call arguments, tool results and file or image attachments. Confirm with a test request that each of these fields reaches the hook in the form you expect, and decide whether to drop, replace or keep each one. Treat any field your test cannot reach as unmasked until you verify it.
Risk that masking misses fields
Pattern-based redaction misses values it was not written to match, such as names in free text, unusual identifier formats or content in nested JSON. Missed content is stored and forwarded silently, so the failure does not show in normal error logs. Ask whether your team will sample logged records on a schedule and who reviews the results, and document that as a residual risk.
Per-team logging opt-outs and who controls them
Can LiteLLM turn off prompt logging for one team only?
Confirm this in the enterprise docs for your release before you promise teams an opt-out. The open-source default records success and error logs without request and response content, and store_prompts_in_spend_logs is described as a gateway-wide setting that you can change from the UI or in config. Team-level logging is listed among Enterprise capabilities, but the scope of each team-level setting can change between releases, so ask the vendor in writing which setting applies to which team and whether it takes effect without a restart. If your policy requires some teams to keep content and others to avoid it, plan for two designs: a gateway-wide default of metadata only with team-level exceptions where your release supports them, or separate gateway instances for teams with different data classes. Test whichever design you choose before a team relies on it.
Which logging controls require an Enterprise license in LiteLLM?
Team-level guardrails and logging, audit logs and organization and team RBAC are the controls that matter most for opt-outs, and they sit in the Enterprise edition. The open-source proxy covers the basic content toggle, so you can keep metadata only across the gateway without a license. Enterprise adds the controls that let you prove and enforce the setting:
- Team-level logging and guardrails, which is where per-team behavior is defined
- Audit logs, which record who changed a setting and when
- Organization and team RBAC, which limits who can change logging configuration
- Secret manager integrations, which keep callback credentials out of config files
Check the enterprise documentation for the exact list in your release, because the free SSO user limit and license terms also affect your budget.
Who should be allowed to change prompt logging settings?
Restrict changes to the platform owner and the security owner, and treat the logging setting as a change that needs approval. Because a single toggle can start capturing personal or confidential content for every team, the person who changes it should be the person who answers for the data. In an open-source deployment, limit admin access through your identity provider and keep the admin UI off public networks. In Enterprise, use organization and team RBAC so team administrators can manage their keys without touching gateway-wide logging. Record each change with audit logs and link it to a ticket that states the team, the reason, the data classes involved and the review date. Review the list of administrators at the same cadence as your other privileged access reviews.
Does a logging opt-out stop audit and investigation needs?
No. An opt-out changes what content is stored, not whether a request happened. Metadata-only logging still records success and error events, so you can still see which key called which model, when, and whether it failed. What you lose is the prompt and response text, which investigators need to judge whether a request exposed personal data or broke an acceptable-use rule. Write the trade-off into policy: state which teams are opted out, who can authorize a temporary change for an investigation, how long that change lasts, and where the captured content is stored and deleted afterward. Involve legal or compliance before the first investigation, not during it, because a content capture approved after an incident may not meet the handling rules your organization applies.
How do per-team opt-outs affect storage and cost?
Content storage is what grows, so an opt-out mainly reduces database growth, backup size and any downstream copies in observability or archive systems. The main recurring costs are the database storage that holds logs, the compute and backup capacity needed to keep it available, and the storage in any archive bucket or SIEM that receives the same records. The main one-time costs are design, configuration and testing of the opt-out. Costs go up when more teams keep content, when retention is long, or when content reaches several destinations. Ask for a quote that lists each storage location, who pays for the database and archive capacity, and how retention and deletion will be enforced. Do not assume that metadata-only logging removes all storage growth, because metadata still accumulates with request volume.
Can DeployOpen set up per-team logging controls for us?
DeployOpen plans, implements, hardens, documents and supports self-hosted platforms in your own infrastructure, which includes setting up LiteLLM logging controls, testing them and preparing the evidence your compliance team asks for. Most engagements are fixed-scope, so the written scope will name the teams, the release, the data classes, the destinations and the tests to be run. Confirm the Enterprise license need with your vendor first, because the license decides which team-level controls are available to configure. DeployOpen does not sell LiteLLM licenses and is not a reseller of the product. A quote follows from the written scope, so the deciding factors are the number of teams, the number of logging destinations and whether your policy needs change control and audit evidence.
How do we test that a team's opt-out actually works?
Test from the team's own keys, not from an administrator account, because admin traffic may be handled differently. Send a test request containing a clearly marked fake personal identifier, then check the spend log record, the admin UI log view, any observability callback, the SIEM and any archive bucket for that text. If you use a masking hook, confirm that masking runs before data leaves the gateway, using the approach described in the scrub data documentation, and check that masked fields do not leave a trace in another destination. Repeat the test after every upgrade, configuration change and callback change. Keep the results as evidence, and include a failed-test procedure that disables the affected key until the gap is fixed.
Security and privacy risks of stored prompts
Storing request and response bodies turns the gateway database and admin UI into a repository of whatever users type or models return. The cards below cover the controls a security reviewer will ask about before approving store_prompts_in_spend_logs, and they name what to confirm in your own environment.
Who can read stored prompts
Once bodies are stored, anyone who can open the request logs in the admin UI or query the PostgreSQL database can read them. Map every role that reaches the logs view, including admins, support staff and read-only users, and confirm which of them should see prompt text at all. Test the UI as each role and check whether direct database access is limited to a small operations group.
Logging docsRetention and deletion of bodies
Stored prompts persist in the database until something removes them, and that is often longer than teams expect. Agree a retention period with legal and privacy owners, then confirm how LiteLLM removes old log rows and whether deleting a single user's content on request is possible. Ask the vendor or your own tests to show that deleted rows are gone from the database, not only hidden in the UI.
Personal data inside prompts
Users paste names, account numbers, medical details and credentials into prompts without being asked, so the stored log becomes a store of personal data. Decide which fields must be masked before they reach any logging callback, using a custom async_logging_hook, and test that masking with realistic sample traffic. Record which teams and data classes the gateway may log in plain text.
Scrub logged data docsAdmin access and change control
Turning on body storage is a configuration change that expands what every admin can see, so it should go through review. Confirm who can change store_prompts_in_spend_logs in config or in the UI, whether that change is recorded, and how the master key that controls the proxy is held. Restrict these permissions to named owners and review them on a set schedule.
Encryption of the data store
Stored bodies sit in PostgreSQL, backups, replicas and any exports, so encryption must cover every copy. Ask whether the database volumes, backup snapshots and replicas are encrypted at rest, who holds the keys, and whether connections to the database use TLS. Include backup copies in the retention review, because a deleted row can still exist in an older backup.
Production guideWhat enabling prompt storage costs and needs
How much effort does it take to turn on prompt and response storage?
Turning on the setting itself is small. LiteLLM stores request and response content only when store_prompts_in_spend_logs is enabled, and you can set it from the admin UI without a restart or in config. The real effort sits around the switch: deciding which teams and models are in scope, confirming the database can absorb larger rows, setting retention, adding masking if sensitive data will pass through, and testing that the stored content looks the way your reviewers expect. Expect most of the time in policy and testing, not in the configuration change.
Can our team enable and run prompt logging without outside help?
Often yes, if you already run LiteLLM with PostgreSQL and have engineers who know the proxy config. The steps are a change to one setting, a test run with synthetic prompts, and a review of what landed in the spend logs. Outside help is more useful when you need a masking hook written and tested, when several teams need different opt-out rules, or when a security or privacy review must accept the design before production. Ask whether your team has capacity to own the masking code and the retention job after the pilot ends.
What drives the cost of storing prompts and responses?
The main cost components are database capacity, retention, masking development and review time. Stored bodies are much larger than metadata rows, so disk growth and backup size rise with traffic and average prompt length. Retention decides how long that growth accumulates. Masking needs an engineer to write and test an async_logging_hook that scrubs data before it reaches logging callbacks. Review time covers your security, privacy and compliance teams. One-time costs include the masking build and the pilot. Recurring costs include storage, backups, retention jobs and periodic re-testing after upgrades. Ask any partner to split the quote along these lines.
What does the work need from our side?
Plan for four inputs before work starts:
- A named policy owner who decides which content may be stored, for which teams and how long it is kept.
- A set of test prompts, including examples with personal or secret-like data, so masking and storage can be verified.
- Database access for the PostgreSQL instance that backs LiteLLM, with rights to check table growth and to run retention jobs.
- Access to the logging destinations and backup systems, so reviewers can confirm where content lands and how it is deleted.
If any of these is missing, the pilot will stall at the first review.
How long does a pilot for prompt storage usually take?
No duration is fixed in the material available for this page, so confirm it in the written scope. A useful pilot covers one team or one model route, a defined retention period, a masking test on the test prompt set, and a review of the stored rows by the policy owner. Ask a partner to name the pilot exit criteria, the number of teams included, and what happens if masking fails the review. The timeline depends mostly on how quickly your policy owner decides and how many test cases your reviewers require.
What should we check in the database before storing prompts?
Check growth before you enable storage for all traffic. Measure current row sizes in the spend logs table, estimate daily volume from a sample period, and confirm backup and restore times still meet your recovery targets with larger rows. LiteLLM recommends PostgreSQL as the primary database and batches spend updates to the database every 60 seconds at scale, so confirm the database has headroom for the added write volume. Test a restore from backup with stored content present, because restoring an unexpectedly large table is a common surprise.
Does enabling prompt storage change our compliance position?
Yes. Storing prompts makes personal or confidential data part of your logs, which brings it under your retention, access and deletion rules. Decide before enabling whether those records need the same protections as other sensitive stores. Work with your privacy and compliance leads to define the retention period, who can read the content, and how deletion requests are handled. DeployOpen prepares systems and evidence for compliance assessments, but it does not issue audit reports or certifications, and an independent auditor or certification body makes that determination.
How DeployOpen scopes prompt logging work
DeployOpen treats prompt and response logging as a data decision before it is a configuration change. We agree in writing what the gateway may store, where it is stored, how long it is kept and which teams can opt out, then build and test those settings in your own infrastructure. The result is a documented logging policy your security and compliance teams can review.
How we scope
- Engagements are fixed-scope, with the logging decision, deliverables and timeline agreed in writing before work starts.
- We confirm which teams and applications send traffic, and whether any prompts are expected to contain personal data or regulated records.
- The written scope names the storage target, retention approach, masking requirements and any per-team opt-outs that apply.
How we build
- We set the default to metadata only and enable store_prompts_in_spend_logs only for the teams and keys that need it.
- We write and test a custom async_logging_hook that masks sensitive fields before data reaches any logging callback.
- We size database growth from a representative test load, then configure cleanup and retention so spend log tables stay manageable.
How we hand over
- You receive the configuration, masking hook source, and a runbook covering how to change the logging setting safely.
- Documentation records which keys, teams and models store bodies, who approved it, and how opt-outs are enforced.
- We walk your platform and security teams through a test request and confirm the stored output matches the written policy.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, so logging settings are reviewed as LiteLLM releases change.
- Retesting the masking hook after upgrades is included in the retainer scope when agreed in writing.
- We can prepare the logging evidence your compliance teams request, though independent auditors issue any assessment outcome.

