Skip to main content

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

Use data.text in your prompt:

Parameters

REST API

POST /v1/memory/context Headers: Authorization: Bearer key_...
Body:
Response:

Format

  • Entries are concatenated into one string, typically separated by newlines or blank lines.
  • Order follows search relevance (highest first). Use limit to control token usage.

When to use

  • RAG / Q&A: Query with the user question, inject data.text into 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.
Next: Memory API reference for full endpoint details.