Context for prompts
The context API runs a semantic search and returns a single formatted string you can drop into a system or user message. No need to manually concatenate search results.SDK
data.text in your prompt:
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace | string | Required. Namespace to search. |
query | string | Query used for semantic search. |
limit | number | Max entries to include in the context string. |
REST API
POST /v1/memory/context
Headers: Authorization: Bearer key_...Body:
Format
- Entries are concatenated into one string, typically separated by newlines or blank lines.
- Order follows search relevance (highest first). Use
limitto control token usage.
When to use
- RAG / Q&A: Query with the user question, inject
data.textinto the system or first user message. - Chat with memory: Before each turn, get context for the last message or conversation summary and append to the prompt.