# How to Disable Memory for a Request in OmniRoute

> Disable request memory in OmniRoute using the x omniroute no memory true header. Learn how to bypass memory injection while keeping the global Memory feature active.

- Repository: [Diego Rodrigues de Sa e Souza/OmniRoute](https://github.com/diegosouzapw/OmniRoute)
- Tags: how-to-guide
- Published: 2026-09-01

---

**Use the HTTP header `x-omniroute-no-memory: true` on any chat request to bypass memory injection while keeping the global Memory feature enabled.**

OmniRoute's **Memory** feature automatically injects conversational context from previous exchanges into chat requests. When you need a stateless, memory-free interaction for a specific request, you can opt out without changing global settings. This guide covers the implementation details, code examples, and how the per-request override works in the OmniRoute source code.

## Understanding OmniRoute's Memory Feature

Memory is **disabled by default** in OmniRoute. The `DEFAULT_MEMORY_SETTINGS` object in [`src/lib/memory/settings.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/src/lib/memory/settings.ts) sets `enabled: false` at lines 27-33, with an explicit comment documenting the `x-omniroute-no-memory` header for per-request opt-out.

When administrators enable Memory through the dashboard UI or API, it applies globally to all chat requests. The `normalizeMemorySettings()` function (lines 99-102) reads the `memoryEnabled` flag from the database and builds the effective configuration object that the chat pipeline consumes.

The `toMemoryRetrievalConfig()` function then evaluates `settings.enabled && settings.maxTokens > 0` to determine whether memory injection should occur. This is where the per-request override takes effect.

## Using the x-omniroute-no-memory Header

The header mechanism is implemented in the memory injection middleware at [`src/open-sse/handlers/chatCore/memorySkillsInjection.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/src/open-sse/handlers/chatCore/memorySkillsInjection.ts). When this middleware detects `x-omniroute-no-memory` with a truthy value, it forces `enabled = false` for that specific request, bypassing all memory retrieval and injection logic.

### cURL Example

```bash
curl -X POST http://localhost:20128/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-omniroute-no-memory: true" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "What is the weather today?"}]
  }'

```

### JavaScript Fetch Example

```javascript
await fetch('/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-omniroute-no-memory': 'true',
  },
  body: JSON.stringify({
    model: 'gpt-4',
    messages: [{ role: 'user', content: 'Explain quantum tunneling.' }],
  }),
});

```

### Node.js Client with OmniRoute SDK

```javascript
import { OmniRouteClient } from '@omniroute/client';

const client = new OmniRouteClient({ baseURL: 'http://localhost:20128' });

await client.chatCompletions({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Summarize the article.' }],
  extraHeaders: { 'x-omniroute-no-memory': 'true' },
});

```

## How the Per-Request Override Works

The memory injection pipeline follows this execution flow:

1. **Request enters Chat Core pipeline** — All chat requests route through the OpenAI-compatible API endpoint.

2. **Middleware inspects headers** — `memorySkillsInjection` checks for `x-omniroute-no-memory`. If present and truthy, it overrides the `enabled` flag to `false` regardless of global settings.

3. **Configuration object built** — `toMemoryRetrievalConfig` creates the `MemoryConfig` with `enabled: false`, which short-circuits the `retrieveMemories` step.

4. **No database queries execute** — With memory disabled, the pipeline skips SQLite and vector store retrieval entirely, eliminating context injection and associated token costs.

5. **Clean LLM response** — The model generates a response based solely on the provided messages, with no historical context from previous conversations.

## Verifying Memory is Disabled for Your Request

To confirm the override succeeded, check these indicators:

- **Response metadata** — Some OmniRoute versions include memory usage stats in response headers or the `usage` object.
- **Token count** — Memory-disabled requests show lower `prompt_tokens` since no context was injected.
- **Behavioral differences** — The model will not reference previous conversation turns even when global Memory is enabled.

The UI at `src/app/(dashboard)/dashboard/settings/components/MemorySkillsTab.tsx` (line 40) displays an internationalized warning explaining this opt-out mechanism to dashboard users. The English translation resides in [`src/i18n/messages/en.json`](https://github.com/diegosouzapw/OmniRoute/blob/main/src/i18n/messages/en.json) at line 6578.

## When to Disable Memory Per-Request

**Cost optimization** — Memory retrieval and injection consumes additional tokens. Disable it for one-off queries where context is irrelevant.

**Stateless operations** — Use when you need deterministic, context-free outputs such as classification tasks, formatting operations, or data extraction.

**Privacy-sensitive requests** — Bypass memory to ensure specific queries are not stored or referenced in future conversations.

**Testing and debugging** — Isolate behavior by eliminating variable context when troubleshooting model responses.

## Summary

- **Default behavior**: Memory is disabled globally in `DEFAULT_MEMORY_SETTINGS` ([`src/lib/memory/settings.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/src/lib/memory/settings.ts)).

- **Per-request opt-out**: Add `x-omniroute-no-memory: true` header to any chat request.

- **Implementation location**: Header detection occurs in [`memorySkillsInjection.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/memorySkillsInjection.ts) middleware.

- **Effect**: Forces `enabled: false` for that request, skipping all memory retrieval and injection.

- **Token savings**: Eliminates context tokens, reducing prompt size and API costs.

## Frequently Asked Questions

### Does disabling memory per-request prevent the conversation from being stored?

No. The `x-omniroute-no-memory` header only controls **retrieval and injection** of past memories into the current request. Whether the exchange is saved for future memory retrieval depends on your persistence settings, which are configured separately.

### Can I disable memory for all requests from a specific API key?

OmniRoute does not natively support per-key memory defaults. You must include the header with each request. For automated disabling, implement a client-side wrapper that injects the header or use a proxy layer that adds it based on your own key-to-policy mapping.

### What happens if I set x-omniroute-no-memory to false or omit it?

Any falsy value or missing header causes the middleware to defer to global settings. If Memory is enabled globally, injection proceeds normally. The header must be explicitly `"true"` (case-insensitive in most HTTP implementations) to trigger the bypass.

### Is there a performance benefit to disabling memory?

Yes. Disabling memory eliminates queries to SQLite and the vector store (`retrieveMemories` is skipped entirely). This reduces latency—measurable on high-volume deployments—and avoids the token overhead of injected context, directly lowering inference costs.