---
title: Data Retention
description: Store and access your full request and response data for debugging, analytics, and compliance.
icon: Database
---

import { Callout } from "fumadocs-ui/components/callout";

# Data Retention

LLM Gateway offers configurable data retention policies that allow you to store full request and response payloads. This enables powerful debugging capabilities, detailed analytics, and compliance with data governance requirements.

## Retention Levels

LLM Gateway supports two retention levels that can be configured per organization:

| Level               | Description                                                                                    | Storage Cost    |
| ------------------- | ---------------------------------------------------------------------------------------------- | --------------- |
| **Metadata Only**   | Stores request metadata (timestamps, model, tokens, costs) without full payloads. Default.     | Free            |
| **Retain All Data** | Stores complete request and response payloads including messages, tool calls, and attachments. | $0.01/1M tokens |

<Callout type="info">
	Metadata-only retention is enabled by default and provides usage analytics
	without additional storage costs.
</Callout>

<Callout type="warning">
	Retention levels are configurable on standard (pay-as-you-go) organizations
	only. DevPass and chat subscriptions are always metadata only — their request
	and response payloads are not retained, and there is no setting to turn
	payload storage on. The Responses API exception below still applies to them.
</Callout>

## Storage Pricing

When full data retention is enabled, storage is billed at **$0.01 per 1 million tokens**. This rate applies to:

- Input tokens (prompt)
- Cached input tokens
- Output tokens (completion)
- Reasoning tokens

Storage costs are calculated per request and billed separately from inference. When "Retain All Data" is enabled, each response's `usage.cost_details` object includes a `data_storage_cost` field with the per-request storage cost in USD. See [Cost Breakdown](/features/cost-breakdown) for the full list of cost fields.

### Example Cost Calculation

For a request with:

- 1,000 input tokens
- 500 output tokens
- 1,500 total tokens

Storage cost = 1,500 / 1,000,000 × $0.01 = **$0.000015**

## Configuring Retention

Data retention is configured at the organization level in your dashboard settings. The setting is only available on standard pay-as-you-go organizations:

1. Navigate to **Organization Settings** → **Policies**
2. Select your preferred **Data Retention Level**
3. Save changes

<Callout type="warning">
	Changing retention settings applies to new requests only. Existing stored data
	follows the retention period active when it was created.
</Callout>

## Retention Periods

Data is retained for 30 days for all users. Enterprise plans can have custom retention periods. After the retention period expires, data is automatically deleted.

<Callout type="info">
	The Responses API does not require data retention. Stored responses (used for
	`previous_response_id` chaining and `GET /v1/responses/:id`) are kept in
	dedicated storage for 30 days — matching OpenAI's own retention — regardless
	of your organization's data retention policy, and are not billed as data
	storage. Because this is independent of the retention level, it applies to
	metadata-only organizations, including DevPass and chat, whose Responses API
	input and output items are therefore held for up to 30 days. Send `store:
	false` with the request to opt out.
</Callout>

## Accessing Stored Data

When data retention is enabled, you can access your stored requests through the dashboard:

- View request history with full payload inspection
- Filter by model and date range
- Inspect complete request and response payloads

## Use Cases

### Debugging

Full data retention enables you to:

- Inspect exact prompts sent to models
- Review complete responses including tool calls
- Trace conversation histories
- Identify issues in production

### Analytics

With stored payloads, you can:

- Analyze prompt patterns and effectiveness
- Track response quality over time
- Build custom dashboards and reports
- Measure model performance across use cases

### Compliance

Data retention helps meet compliance requirements by:

- Maintaining audit trails of AI interactions
- Enabling data governance policies
- Supporting incident investigation
- Providing records for regulatory requirements

## Billing Considerations

### Credit Usage

In **API keys mode** (using your own provider keys):

- Only storage costs are deducted from LLM Gateway credits
- Inference costs are billed directly to your provider

In **credits mode**:

- Both inference and storage costs are deducted from credits

### Monitoring Storage Costs

Storage costs appear in:

- Usage dashboard under "Storage" category
- Billing invoices as a separate line item

<Callout type="success">
	Enable [auto top-up](https://llmgateway.io/dashboard) in billing settings to
	ensure uninterrupted service when storage costs accumulate.
</Callout>

## Self-Hosted Deployments

Self-hosted deployments have full control over data retention:

- Configure retention periods in environment variables
- Data is stored in your own PostgreSQL database
- No additional storage costs (you manage your own infrastructure)

## Privacy and Security

- All stored data is encrypted at rest
- Access is restricted to organization members with appropriate permissions
- Data is automatically deleted after the retention period
- You can request immediate deletion of specific records through support
