Skip to content
unlob
GET

/assemble_context

GraphRAG as a single call: a corroborated, story-deduplicated, trust-ranked context pack fitted to a token budget, with a reason attached to every passage.

The usual retrieval loop is: search, deduplicate, assess trust, verify against other sources, rank, truncate to fit the context window. That is five or six round trips of agent reasoning and a lot of tokens spent deciding what not to read.

assemble_context runs that loop server-side. It retrieves a story-collapsed pool, ranks it by corroboration first, then authority, then relevance, and packs it to the token budget you specify.

Every item comes back with the reason it was included. Agents that must show their work — which is most of them, in production — get an explainable context set rather than an opaque blob.

Request

GET /assemble_contextbash
curl -H "x-api-key: $UNLOB_API_KEY" \
  "https://api.unlob.com/assemble_context?q=who+funds+independent+web+indexes&budget=4000"
ParameterTypeDescription
qrequiredstringThe question to assemble context for.
budgetinteger

default: 4000

Token budget for the pack.
langstringLanguage restriction.
min_independent_sourcesintegerRequire corroboration before inclusion.

Response

{ query, token_budget, estimated_tokens, items: [{ hit, reason }] }

Example responsejson
{
  "query": "who funds independent web indexes",
  "token_budget": 4000,
  "estimated_tokens": 3820,
  "items": [
    {
      "hit": { "url": "https://...", "host": "techcrunch.com", "independent_sources": 5 },
      "reason": "corroborated by 5 independent hosts; highest centrality in cluster"
    }
  ]
}

From an agent

This endpoint is also exposed as the MCP tool assemble_context, so an agent can call it without any HTTP code.

mcp: assemble_contextjson
// Get me everything I need to answer this question, in 4,000 tokens.
{ "query": "who funds independent web indexes", "budget": 4000 }

Try this endpoint

Every endpoint is available on the free tier. Get a key and run the example above unchanged.