When you log requests through PromptLayer, we process and index the data to make it searchable. Understanding how your data is indexed will help you write more effective filters when using the Search Request Logs API or the dashboard’s advanced search.Documentation Index
Fetch the complete documentation index at: https://docs.promptlayer.com/llms.txt
Use this file to discover all available pages before exploring further.
How Data Gets Indexed
PromptLayer takes your request data — the prompt input, model output, metadata, and input variables — and flattens nested structures into searchable key-value pairs. This allows you to filter on deeply nested fields using dot-notation paths. For example, if your output is:result.status→"approved"result.score→0.95
Input Text
For chat requests,input_text is built by combining all messages except the last assistant message. Each message is prefixed with its role in brackets and joined with double newlines:
input_text alongside system prompts, user messages, and other roles (e.g. tool results). Only the final assistant message is excluded — it is indexed separately as the output.
The role prefixes are part of the indexed text, so a search for "[system]" would match requests that have a system prompt.
Output
How the LLM output is indexed depends on the output type:JSON Output
When the model returns a valid JSON object (e.g.{"key": "value"}), PromptLayer flattens it into searchable key-value pairs. All keys become available in output_keys, and all values become filterable through the output field.
JSON arrays (e.g. [1, 2, 3]) and other JSON primitives are treated as plain text — only JSON objects are flattened.
Tool Call Output
When the model makes tool calls, the entire tool call structure is wrapped in a{"tool_calls": [...]} object and then flattened using dot-notation. Array indices are stripped, so if the model calls multiple tools, their fields are grouped together under the same keys.
For example, a tool call like:
tool_calls.idtool_calls.typetool_calls.function.nametool_calls.function.arguments.querytool_calls.function.arguments.limit
search_database and send_email, the key tool_calls.function.name will contain ["search_database", "send_email"]. Filtering on that key will match if any of the values match — so key_equals with "search_database" will find requests that called search_database, even if other tools were also called.
Tool names are also extracted into the tool_names array for easy filtering — this is typically the simplest way to filter by tool.
Plain Text Output
When the model returns plain text (not JSON, no tool calls), theoutput and output_keys fields will be empty — there are no structured keys to flatten. The raw text is still stored in output_text and searchable via q.
Free-Text Search Across All Output Types
Theoutput_text field is always populated regardless of output type, so the q parameter works across all requests:
- Plain text:
output_textcontains the raw output - JSON:
output_textcontains a text representation of each flattened key-value pair (e.g."status: approved\nscore: 0.95") - Tool calls:
output_textcontains any assistant text content combined with the flattened tool call values
q searches across all output types — you don’t need to know the output format to find requests by content.
Metadata
Metadata key-value pairs are always fully indexed. Every key and value you provide becomes searchable.{"user": {"id": "abc", "role": "admin"}}, you can filter on user.id and user.role.
Input Variables
For example, if your prompt template uses{question} and {context}, but you also pass user_id as an input variable:
question and context are searchable as input variables. To make user_id searchable, pass it as metadata.
Exact Match vs. Text Search
When filtering nested fields (metadata, output, input_variables), the matching behavior depends on the operator and the nature of the stored value:-
key_equalsandkey_not_equalsperform exact matching. These work best with short, discrete values like IDs, status codes, numbers, and enum-like strings. -
key_containsperforms partial text matching. This is better suited for longer text values, sentences, or when you only know part of the value.
Quick Reference
| Field | What’s Indexed | When |
|---|---|---|
output / output_keys | Flattened JSON keys and values | JSON or tool call output only |
output_text | Raw output text | Always (searchable via q) |
metadata / metadata_keys | All key-value pairs | Always |
input_variables / input_variable_keys | Flattened key-value pairs | Only for variables referenced in the prompt template |
tags | Tag names | Always |
tool_names | Tool/function names | Tool call output only |
Related
- Search Request Logs API - API reference for filtering
- Metadata - Attaching metadata to requests
- Advanced Search - Using search in the dashboard

