API Reference - Entity Enricher Documentation

API Reference

The Entity Enricher REST API lets you enrich entities, manage schemas, and retrieve records programmatically. All responses are JSON. Real-time progress uses Server-Sent Events (SSE).

Quick Start

Integrate Entity Enricher in three steps:

1

Get Schema

GET /api/schema/saved

List saved schemas or generate one from sample data

2

Enrich

POST /api/single/enrich/stream

Start enrichment, get a job ID for SSE streaming

3

Get Result

GET /api/records/{id}

Retrieve the full enrichment record with structured output

Authentication

All API endpoints (except login/register) require authentication. Use the X-API-Key header with an organization access key:

curl -H "X-API-Key: ent_your_key_here" \
     https://your-instance.example.com/api/enrichment/options

Create API keys from the API Keys page or via POST /api/auth/api-keys. See the API Keys guide for details on key types and permissions.

Key Endpoints

Enrichment

MethodEndpointDescription
GET/api/enrichment/optionsAvailable models, languages, and strategies
POST/api/single/enrich/streamStart single entity enrichment (returns job_id)
POST/api/enrichment/batch/startStart batch enrichment for multiple entities
POST/api/enrichment/batch/fetchFetch entities from an external URL

Job Management

MethodEndpointDescription
GET/api/llm/stream/{job_id}SSE stream for any LLM job (enrichment, schema, fusion)
POST/api/llm/cancel/{job_id}Cancel a running or paused job
POST/api/llm/continue/{job_id}Resume a paused job (e.g., after classification mismatch)

Schemas

MethodEndpointDescription
GET/api/schema/savedList all saved schemas
POST/api/schema/savedCreate a new schema
POST/api/schema/generate/streamGenerate schema from sample data (SSE)
POST/api/schema/saved/{id}/prompt/streamAI-edit schema with natural language (SSE)

Records & Fusion

MethodEndpointDescription
GET/api/recordsList records with pagination and filtering
GET/api/records/{id}Get full record detail with structured output
POST/api/records/batch-deleteDelete multiple records (max 100)
POST/api/fusion/mergeMerge results from multiple models

SSE Streaming

Enrichment, schema generation, and fusion operations use Server-Sent Events for real-time progress. Start a job, get a job_id, then connect to the SSE stream:

SSE Event Flow

data: {"type":"model_started","model":"anthropic::claude-sonnet-4-5"}
data: {"type":"expertise_completed","expertise_key":"financial","partial_result":{...}}
data: {"type":"model_completed","success":true,"result":{...},"record_id":"uuid"}
data: {"type":"completed"}

Key Event Types

EventDescription
model_startedModel processing begins
expertise_completedOne expertise domain finished (with partial results)
model_completedModel finished with result, record_id, and cost
fusion_started / fusion_completedMulti-model fusion lifecycle events
entity_started / entity_completedBatch-specific per-entity events (include entity_index)
completedTerminal event - close the connection
errorJob-level error occurred

Python Example

A complete workflow that lists schemas, starts enrichment, streams results, and retrieves the final record:

import httpx
import json

BASE = "https://your-instance.example.com"
KEY = "ent_your_api_key"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

# 1. List saved schemas
schemas = httpx.get(f"{BASE}/api/schema/saved", headers=HEADERS).json()
schema_id = schemas["schemas"][0]["id"]

# 2. Start enrichment
resp = httpx.post(f"{BASE}/api/single/enrich/stream", headers=HEADERS, json={
    "entity_data": {"name": "Moderna Inc", "country": "US"},
    "schema_id": schema_id,
    "models": ["anthropic::claude-sonnet-4-5-20250514"],
    "strategy": "multi_expertise",
})
job_id = resp.json()["job_id"]

# 3. Stream SSE events
record_id = None
with httpx.stream("GET", f"{BASE}/api/llm/stream/{job_id}", headers=HEADERS) as stream:
    for line in stream.iter_lines():
        if not line.startswith("data: "):
            continue
        event = json.loads(line[6:])

        if event["type"] == "model_completed" and event.get("record_id"):
            record_id = event["record_id"]
        elif event["type"] == "completed":
            break

# 4. Retrieve the enrichment record
if record_id:
    record = httpx.get(f"{BASE}/api/records/{record_id}", headers=HEADERS).json()
    print(json.dumps(record["structured_output"], indent=2))

curl Example

Start a batch enrichment with two models and stream the results:

# Start batch enrichment
JOB_ID=$(curl -s -X POST \
  -H "X-API-Key: $KEY" \
  -H "Content-Type: application/json" \
  "$BASE/api/enrichment/batch/start" \
  -d '{
    "entities": [
      {"name": "Pfizer Inc", "country": "US"},
      {"name": "Roche", "country": "CH"}
    ],
    "schema_id": "your-schema-uuid",
    "models": ["anthropic::claude-sonnet-4-5-20250514", "openai::gpt-4o"],
    "strategy": "multi_expertise",
    "arbitration_model": "anthropic::claude-sonnet-4-5-20250514"
  }' | jq -r '.job_id')

# Stream events
curl -N -H "X-API-Key: $KEY" "$BASE/api/llm/stream/$JOB_ID"

# List resulting records
curl -s -H "X-API-Key: $KEY" \
  "$BASE/api/records?type=enrichment&page_size=10" | jq '.records'

Error Handling

StatusMeaningExample
200SuccessRequest completed
400Bad requestInvalid model key or missing field
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient role for this endpoint
404Not foundRecord, schema, or job not found
500Server errorInternal failure

Error responses include a detail field with a human-readable error message. SSE streams emit an error event type before the terminal completed event if something fails mid-stream.

Model Composite Keys

Models are identified by composite keys in the format provider_name::model_name. Use GET /api/enrichment/options to list available models and their keys.

Anthropic
anthropic::claude-sonnet-4-5-20250514
OpenAI
openai::gpt-4o
Google
google::gemini-2.5-pro
DeepSeek
deepseek::deepseek-chat

Interactive API Documentation

The application includes interactive API documentation with request/response examples. Requires admin authentication to access:

Next Steps