Context

The most important endpoint for AI agents. It returns the most relevant memories for a specific task, ready to insert into the prompt.

Build context

POST/api/v1/context/build
bash
curl -s -X POST "$SOLUCORTEX_URL/api/v1/context/build" \
  -H "Authorization: Bearer $SOLUCORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "project_id": "'"$SOLUCORTEX_PROJECT_ID"'",
    "query": "implement authentication with rotatable API keys"
  }'

Parameters

FieldTypeRequiredDescription
project_idUUIDProject UUID
querystringTask or question description. The more specific, the better the result.
limitintMaximum memories to return. Default: 15

Response

json
{
  "query": "implement authentication with rotatable API keys",
  "project": { "id": "...", "name": "My Project" },
  "memories": [
    {
      "id": "uuid",
      "type": "decision",
      "title": "API keys with scx_ prefix and SHA-256 hash",
      "content": "API keys are stored as hashes to avoid exposure...",
      "importance": 9,
      "summary": "Summary automatically generated by OpenAI",
      "score": 0.94
    }
  ],
  "context_text": "--- MEMORY 1 (importance: 9) ---\nAPI keys with scx_ prefix..."
}

Use context_text directly in the agent system prompt.


How to use it in an agent

Claude Code / Claude API

bash
#!/bin/bash
source ai/.env.ai

# 1. Load context
CONTEXT=$(curl -s -X POST "$SOLUCORTEX_URL/api/v1/context/build" \
  -H "Authorization: Bearer $SOLUCORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"project_id\": \"$SOLUCORTEX_PROJECT_ID\",
    \"query\": \"$1\"
  }" | jq -r '.context_text')

# 2. Use the context
echo "Loaded context:"
echo "$CONTEXT"

Included bootstrap script

bash
source ai/.env.ai
bash ai/runtime/bootstrap/load-context.sh "describe your task here"

Snapshots

Snapshots are immutable pictures of context. They are useful for auditing or comparing knowledge at different moments.

POST/api/v1/snapshots
GET/api/v1/snapshots/{id}
bash
# Create a snapshot of the current state
curl -s -X POST "$SOLUCORTEX_URL/api/v1/snapshots" \
  -H "Authorization: Bearer $SOLUCORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "'"$SOLUCORTEX_PROJECT_ID"'",
    "label": "Pre-deploy v1.2.0"
  }'