Skip to main content
LLM Enrich stage showing structured data extraction with language models
The LLM Enrich stage uses language models to extract structured data from document content. It can identify entities, classify content, extract key information, and generate structured outputs.
Stage Category: ENRICH (Enriches documents)Transformation: N documents → N documents (with extracted data added)

When to Use

When NOT to Use

Parameters

The stage also accepts multimodal_inputs, api_key and feature_uri, described in the sections below. Each document is sent to the model as content, with embedding vectors, blobs and internal bookkeeping fields removed, and prompt as the instruction. To point the model at a specific field, reference it in the prompt with {{DOC.field_name}}.
The stage accepts at most max_candidates documents (10 unless you set it, 50 at most). When more reach it, the run is refused with a 400 before any model call. The error gives the count, the cap and the cost of enriching them all. Reduce the working set with an earlier filter or reduce stage, or a smaller final_top_k. You can also raise max_candidates.
Each document in the run’s results costs 2 credits. Explain prices the stage that way before you run it, and says when the run would be refused. Its plan for the stage names the model in model and counts the candidates that reach it. That count reads the final_top_k of the search before it.

Available Models

jev-latest is Jev, an evaluation model from TypeSafe AI. It requires an output_schema, and every field needs a closed set of values: A string field named reason, reasoning, explanation, rationale or justification is filled with the probabilities behind the answer. Any other free-text field is rejected when you create the retriever, and the error names the field.

Configuration Examples

Output Schema

Define structured output using JSON Schema:

Supported Types

Output Examples

Without Schema

With Schema

Performance

LLM enrichment is expensive. Consider pre-computing extractions during indexing for frequently accessed data.

Media per document

With include_media: true, each document’s media goes to the model with its fields. The model answers the prompt from what the media shows. Each document is its own call, and the calls run concurrently.
  • With provider: google, the video in video_field is sent. A document with no video sends its image.
  • Other providers get the image in image_field (or thumbnail_url, then image_url) and no video.
  • A custom plugin gets the video as media.
Media is read from the field as stored. An http(s) URL is sent as it is. A storage path is sent only when it is in this namespace’s storage. A path in another namespace is never sent, even in the same organization. A video must be under 20 MB. When a document’s media cannot be sent, the model does not answer for that document. Its output_field holds an error with a failure_mode: The run reports how many documents failed and why.
include_media cannot be combined with provider: typesafe.

Media without fields

By default the model gets each document’s fields as text beside its media, such as its start and end times, duration and any stored descriptions. Set include_document_text: false to send the prompt and the media only. A collection’s extractor reads a segment the same way, with its prompt and the clip and nothing else, so use this to ask a clip at query time the question a stored layer asked it, and compare the answers. It needs include_media: true. To send the request the extractor sent, also set prompt_as_written: true, along with the extractor’s temperature and top_p, and thinking_budget: 0, since the extractor turns thinking off. Without it, the stage adds a line about the operation and a copy of the output schema to the prompt, and sends the media after the text. With it, the model gets the media and then your prompt, and the schema goes only as Gemini’s response schema.

Sampling rate

With provider: google, the model reads a video as frames sampled at 1 per second. A 3-second clip gives it about three frames, so something on screen for under a second can fall between two frames and be missed on every call. Set video_fps to sample more often. At video_fps: 4 the model reads a frame every 0.25 s. Each sampled frame adds about 258 input tokens, so a 3-second clip costs about 800 input tokens at 1 frame per second and about 3,100 at 4. The stage is billed per document, at the same rate for any video_fps. video_fps is refused without include_media: true, with a provider other than google, and with feature_uri.

Common Pipeline Patterns

Search + Extract + Filter

Entity Extraction Pipeline

Writing Effective Prompts

Good Prompts

Poor Prompts

Be specific about what to extract and in what format. When using output_schema, the LLM will conform to the structure.

Multimodal Query Inputs

Pass images from your query inputs to the LLM alongside document content. This enables visual comparison, brand matching, and cross-modal analysis.

Parameters

How It Works

  1. Declare which INPUT fields carry multimodal content via multimodal_inputs
  2. At runtime, the stage extracts URLs from {{INPUT.field_name}}
  3. Images are sent to the LLM alongside the prompt and document content
  4. Works with providers that support vision (Google Gemini, OpenAI GPT-4o, Anthropic Claude)

Configuration Examples

Calling with Multimodal Inputs

When using multimodal_inputs, pass the image URLs in the retriever’s inputs:
If a declared multimodal input field is missing from the query inputs at runtime, the stage proceeds without it (text-only mode). No error is raised.

Bring Your Own Key (BYOK)

Use your own LLM API keys instead of Mixpeek’s default keys. This gives you control over costs, rate limits, and API usage.

Why Use BYOK?

Setup

1

Store your API key as a secret

Store your LLM provider API key in the organization secrets vault:
2

Reference the secret in your stage

Use the api_key parameter with template syntax:

BYOK Configuration Example

Supported Providers

When api_key is not specified, the stage uses Mixpeek’s default API keys and usage is charged to your Mixpeek account.

Custom Enrichment Model (BYO Plugin)

Use your own enrichment model deployed as a custom extractor instead of a hosted LLM provider. Set feature_uri to route enrichment through your extractor’s inference endpoint.

Parameters

Your plugin receives {prompt: str, document: dict}, plus media: {kind, url} when include_media is on. Without output_schema it returns {text: str}. With output_schema, your plugin’s return value is checked against the schema and written to output_field as is. It may be an object or a JSON string. A value that does not match gives that document an error with failure_mode invalid_output, naming the first field that failed. A returned error key gives plugin_error. A plugin that scales to zero can be slow to answer its first call. Explain shows its published start time as cold_start_s.

Configuration Example

Set inference_type: "generate" in your plugin’s manifest to declare compatibility with LLM stages.

Error Handling

A document whose call fails keeps its fields as they were: the stage does not set output_field on it. The response’s warnings name the failures with their failure_mode and a count, status is degraded, and the stage’s statistics list each failed call. A stage whose every call failed is not billed.

Call llm_enrich from the API

Add the stage to a retriever’s stages array as {"stage_name": "<your label>", "stage_type": "enrich", "config": {"stage_id": "llm_enrich", "parameters": {...}}}. The parameters are the ones on this page.