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

# Prompt handling

> The four fields that change what we send the provider and what we keep.

Your prompt passes through us on the way to the provider. Four fields decide what we do with it. We remove all four from the body before we call the provider, so the provider never sees them.

| Field           | What it does                                             | Where it works   |
| --------------- | -------------------------------------------------------- | ---------------- |
| `pii_mask`      | Replaces personal data with placeholders before we send  | Managed Keys     |
| `moderate`      | Checks the prompt for harmful content before we send     | Managed Keys     |
| `trace_storage` | Keeps the prompt and the answer for the Logs page        | Managed Keys     |
| `cache`         | Bills a repeated Claude prefix at one tenth of the price | Anthropic direct |

The first three only run on Managed Keys. On your own keys we forward your request untouched.

Masking and moderation read your request first, then your organization's default, then off. Trace storage reads the request and nothing else.

## PII masking

We can mask personal data in your prompt before it reaches the provider. Each match becomes a stable placeholder such as `[EMAIL_1]`, so the model can still tell people apart. It covers emails, phone numbers, and other patterns such as card numbers.

```json theme={null}
{ "pii_mask": true }
```

Send `false` on one request to skip masking that your organization turned on. If masking is on and it fails, we stop the request with `500` [`pii_masking_failed`](/errors#pii_masking_failed) rather than send it unmasked.

## Moderation

We can check a prompt for harmful content before sending it. A blocked prompt returns `403` [`moderation_blocked`](/errors#moderation_blocked) and reaches no provider.

```json theme={null}
{ "moderate": true }
```

## Trace storage

We can store your prompts and answers, encrypted, so the Logs page can show them. Only your request turns this on. A managed request otherwise keeps what a BYOK request keeps, which is billing data and nothing else.

```json theme={null}
{ "trace_storage": true }
```

A later request without the field stores nothing new. What you already stored stays until you delete it on the Logs page.

## Prompt caching

We cache every Claude request on the direct Anthropic route. A repeated prefix then bills at one tenth of the normal input price. Writing the cache costs 1.25 times input price. A prefix you never reuse costs 25 percent more. That's why you can turn caching off.

```json theme={null}
{ "cache": false }
```

Your own markers always win. If your request has any `cache_control`, we forward it and add nothing of our own. A request too short to cache just runs uncached.

| Route             | What happens                                                             |
| ----------------- | ------------------------------------------------------------------------ |
| Anthropic direct  | Automatic, and your own markers override it                              |
| Bedrock           | Your explicit markers only, since Bedrock has no automatic caching       |
| OpenAI and Gemini | The provider caches repeated prefixes itself, so there is nothing to set |

The response reports `cached_tokens` and `cache_write_tokens` in its usage block.

## Identity fields on managed keys

On Managed Keys we replace four identity fields with a stable hash of your organization id before we call the provider. The identity a provider sees on our credential has to come from us, so these are the only fields we change instead of forwarding.

* `user`
* `safety_identifier`
* `prompt_cache_key`
* `metadata.user_id`

On your own key we forward all four as you sent them.

| Field               | Managed Keys                         | Your own key |
| ------------------- | ------------------------------------ | ------------ |
| `user`              | Removed                              | Forwarded    |
| `safety_identifier` | Your organization hash, on OpenAI    | Forwarded    |
| `prompt_cache_key`  | Your organization hash, on OpenAI    | Forwarded    |
| `metadata.user_id`  | Your organization hash, on Anthropic | Forwarded    |

We leave every other key in `metadata` alone.

Workers AI takes no identity field on the body, so we attach the hash to the request itself instead. Gemini, Vertex and Bedrock take no identity field we can set. On those three routes we remove yours and send nothing in its place.

## One reserved marker in tool call ids

Gemini needs a signature replayed with each tool call, so we carry it inside the tool call id. The id we hand you looks like `<id>::gsig::<signature>`, and we take the signature back off before any other provider sees it.

Your own ids pass through untouched, even when they contain `::`. The one thing to avoid is the literal text `::gsig::` inside an id you invent, because we'd read it as ours and cut the id short.

## File names on Gemini models

You can send a document inline, as base64 bytes or as a `data:` URL. On a Gemini model we send Google the media type and the bytes, and we leave out `filename` and `file_id`. Google's document format has no field for them and rejects a request that carries one. The model reads the bytes and never sees a name, so nothing you sent is lost.

Every other provider still gets the name.
