Skip to main content
POST
/
contexts
/
{context_name}
/
resolve
curl -X POST \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scopes": {
      "user_id": 123,
      "project": "web-app"
    },
    "query": "user authentication issues"
  }' \
  https://api.contextbase.dev/v1/contexts/user-interactions/resolve
{
  "content": "USER CONTEXT: User ID 123 has previously reported login issues on 2024-01-15. Recent interactions show confusion about password reset flow. User preferences: technical explanations, quick solutions.\n\nINTERACTION HISTORY: User asked about password reset but seemed confused about email verification step. Frustration level: moderate. Previous attempts: 3.",
  "metadata": {
    "token_count": 847
  }
}

Overview

The context resolve endpoint fetches compressed, data-rich content from a single context. This is useful when you only need content from one specific context source, rather than combining multiple contexts together. For combining multiple contexts in a specific order, use the prompt resolve endpoint.

Path Parameters

context_name
string
required
Name of the context to resolve (e.g., “user-interactions”, “knowledge-base”)

Request Body

scopes
object
Scoping parameters to personalize the context. These filter the context to include only data relevant to specific users, projects, or environments.
query
string
Optional query string for RAG contexts. This helps filter and rank relevant content, preventing context rot by including only information semantically similar to your query.

Response

content
string
required
The compressed context content, optimized for prompting your LLM with relevant contextual awareness from this specific context.
metadata
object
Additional metadata about the resolved context.

Example Request

curl -X POST \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scopes": {
      "user_id": 123,
      "project": "web-app"
    },
    "query": "user authentication issues"
  }' \
  https://api.contextbase.dev/v1/contexts/user-interactions/resolve

Example Response

{
  "content": "USER CONTEXT: User ID 123 has previously reported login issues on 2024-01-15. Recent interactions show confusion about password reset flow. User preferences: technical explanations, quick solutions.\n\nINTERACTION HISTORY: User asked about password reset but seemed confused about email verification step. Frustration level: moderate. Previous attempts: 3.",
  "metadata": {
    "token_count": 847
  }
}

Use Cases

  • Single-Source Context: Get context from one specific data source (user interactions, knowledge base, etc.)
  • Focused AI Responses: Generate responses based on one type of context without mixing data sources
  • Context Testing: Test individual contexts before combining them in prompts
  • Lightweight Applications: Simple use cases that don’t need multiple context sources

How Context Resolution Works

  1. Data Collection: All published data within the context is gathered
  2. Scope Filtering: Only data matching your scopes is included (e.g., specific user’s data)
  3. RAG Filtering: If query provided, only semantically relevant content is selected
  4. Content Compression: The context content is compressed and optimized
  5. Token Limiting: Result is trimmed to respect context token limits
  6. Structured Output: Final compressed context ready for your LLM prompts

When to Use Context vs Prompt Resolve

  • Use Context Resolve: When you need content from a single, specific context
  • Use Prompt Resolve: When you need to combine multiple contexts in a specific order
  • Single contexts: User interactions, knowledge base articles, system logs
  • Multiple contexts: Complete AI prompts combining user data + knowledge + system info