# Caching

URL: https://interfaze.ai/docs/caching

Most document workloads are not one request per file. You extract fields, re-run with a different schema, then ask a follow up question, all against the same file.

Interfaze caches the expensive part of the first pass, such as decoding the file and running the specialized model. Repeated requests on the same file or a very similar prompt reuse that work instead of redoing it.

Caching is on by default, cached outputs are not charged again, and there is no separate cache bill.

## Detecting a cache hit

Every chat completion response carries a `vcache` boolean that tells you whether it was served from the verified cache.

**Interfaze SDK · typescript**

```typescript
const response = await interfaze.chat.completions.create({
  messages: [{ role: "user", content: `Summarize this paper\n${paperUrl}` }],
});

// false on the first request, true on the ones after it
console.log({ cached: response.vcache, tokens: response.usage?.total_tokens });
```

**Interfaze SDK · python**

```python
response = interfaze.chat.completions.create(
    messages=[{"role": "user", "content": f"Summarize this paper\n{paper_url}"}],
)

print({"cached": response.vcache, "tokens": response.usage.total_tokens})
```

## Bypassing the cache

Some workloads need a fresh run every time, such as scraping a page that changes by the minute or re-running a search for the newest results.

Skip the cache for a request with the `x-interfaze-bypass-cache` header:

```text
x-interfaze-bypass-cache: true
```

If you use the [Interfaze SDK](https://interfaze.ai/docs/integrations/interfaze-sdk), set `bypassCache: true` when creating the client instead and the header is added for you. With any other SDK, set the header as a default header on the client so every request carries it.

**Interfaze SDK · typescript**

```typescript
import { Interfaze } from "interfaze";

const interfaze = new Interfaze({
  apiKey: process.env.INTERFAZE_API_KEY,
  bypassCache: true, // always run the request fresh
});
```

**Vercel AI SDK · typescript**

```typescript
import { createOpenAI } from "@ai-sdk/openai";

const interfaze = createOpenAI({
  baseURL: "https://api.interfaze.ai/v1",
  apiKey: process.env.INTERFAZE_API_KEY,
  headers: {
    "x-interfaze-bypass-cache": "true",
  },
});
```

**LangChain SDK · typescript**

```typescript
import { ChatOpenAI } from "@langchain/openai";

const interfaze = new ChatOpenAI({
  configuration: {
    baseURL: "https://api.interfaze.ai/v1",
    defaultHeaders: {
      "x-interfaze-bypass-cache": "true",
    },
  },
  apiKey: process.env.INTERFAZE_API_KEY,
  model: "interfaze-beta",
});
```

**Interfaze SDK · python**

```python
import os
from interfaze import Interfaze

interfaze = Interfaze(
    api_key=os.environ["INTERFAZE_API_KEY"],
    bypass_cache=True,  # always run the request fresh
)
```

**LangChain SDK · python**

```python
import os
from langchain_openai import ChatOpenAI

interfaze = ChatOpenAI(
    base_url="https://api.interfaze.ai/v1",
    api_key=os.environ["INTERFAZE_API_KEY"],
    model="interfaze-beta",
    default_headers={"x-interfaze-bypass-cache": "true"},
)
```

Bypassed requests are billed as fresh calls, so keep the cache on unless you specifically need real-time results.

Learn more about [lowering costs and improving speed](https://interfaze.ai/docs/lower-costs-and-improve-performance).
