> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pezzo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Request Caching

Pezzo provides you with out-of-the-box request caching capabilities. Caching is useful in several scenarios:

* Your LLM requests are relatively static
* Your LLM requests take a long time to execute
* Your LLM requests are expensive

Utilizing caching can sometimes reduce your development costs and execution time by over 90%!

## Usage

To enable caching, simply set the `X-Pezzo-Cache-Enabled: true` header. Here is an example:

<Tabs>
  <Tab title="Node.js">
    ```ts theme={null}
    const response = await openai.chat.completions.create({
      model: "gpt-3.5-turbo",
      messages: [
        {
          role: "user",
          message: "Hello, how are you?"
        }
      ]
    }, {
      headers: {
        "X-Pezzo-Cache-Enabled": true,
      }
    });

    ```
  </Tab>

  <Tab title="Python">
    ```py theme={null}
    chat_completion = openai.chat.completions.create(
      model="gpt-3.5-turbo",
      messages=[
        {
          "role": "user",
          "content": "Tell me 5 fun facts about yourself",
        }
      ],
      headers={
        "X-Pezzo-Cache-Enabled": "true"
      }
    )
    ```
  </Tab>
</Tabs>

## Cached Requests in the Console

Cached requests will will be marked in the **Requests** tab in the Pezzo Console:

<Frame style={{ maxWidth: 600 }}>
  <img src="https://mintcdn.com/pezzo/UxIQ-tH2DA-EnUD8/client/cache-requests-list.png?fit=max&auto=format&n=UxIQ-tH2DA-EnUD8&q=85&s=095499fadb3b9e0e3aaaca44daa17e11" width="2278" height="1618" data-path="client/cache-requests-list.png" />
</Frame>

When inspecting requests, you will see whether cache was enabled, and whether there was a cache hit or miss:

<Frame style={{ maxWidth: 500 }}>
  <img src="https://mintcdn.com/pezzo/UxIQ-tH2DA-EnUD8/client/cache-request-details.png?fit=max&auto=format&n=UxIQ-tH2DA-EnUD8&q=85&s=e1b76885388208c7b93b7570ba02e832" width="706" height="472" data-path="client/cache-request-details.png" />
</Frame>

## Limitations

Requests will be cached for 3 days by default. This is currently not configurable.
