API 참조 - Entity Enricher 문서

API 참조

Entity Enricher REST API를 사용하면 엔터티를 강화하고, 스키마를 관리하며, 레코드를 프로그래밍 방식으로 검색할 수 있습니다. 모든 응답은 JSON입니다. 실시간 진행 상황은 Server-Sent Events(SSE)를 사용합니다.

빠른 시작

세 단계로 Entity Enricher를 통합합니다:

1

스키마 가져오기

GET /api/schema/saved

저장된 스키마를 나열하거나 샘플 데이터로부터 하나를 생성합니다

2

보강

POST /api/single/enrich/stream

강화를 시작하고 SSE 스트리밍용 작업 ID를 받으세요

3

결과 가져오기

GET /api/records/{id}

구조화 출력과 함께 전체 enrichment record를 조회합니다

인증

모든 API 엔드포인트(로그인/등록 제외)는 인증이 필요합니다. 조직 액세스 키와 함께 X-API-Key 헤더를 사용하세요:

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

API Keys 페이지 또는 POST /api/auth/api-keys를 통해 API key를 생성하세요. key 유형과 권한에 대한 자세한 내용은 API Keys 가이드를 참조하세요.

주요 엔드포인트

보강

메서드엔드포인트설명
GET/api/enrichment/options사용 가능한 model, 언어 및 전략
POST/api/single/enrich/stream단일 엔터티 강화 시작 (SSE용 job_id 반환)
POST/api/single/enrich/sync비 SSE 클라이언트(Make.com, curl)를 위한 블로킹 단일 보강
POST/api/enrichment/batch/start여러 엔터티에 대한 배치 강화 시작
POST/api/enrichment/batch/fetch외부 URL에서 엔터티를 가져옵니다

작업 관리

메서드엔드포인트설명
GET/api/llm/stream/{job_id}모든 LLM 작업(강화, 스키마, 융합)을 위한 SSE 스트림
POST/api/llm/cancel/{job_id}실행 중이거나 일시 중지된 작업을 취소합니다
POST/api/llm/continue/{job_id}일시 중지된 작업 재개(예: 분류 불일치 후)

스키마

메서드엔드포인트설명
GET/api/schema/saved저장된 모든 스키마 목록 표시
POST/api/schema/saved새 schema 생성
POST/api/schema/generate/stream샘플 데이터에서 스키마 생성 (SSE)
POST/api/schema/saved/{id}/prompt/stream자연어로 스키마 AI 편집 (SSE)

레코드 및 융합

메서드엔드포인트설명
GET/api/records페이지네이션 및 필터링으로 레코드 목록 표시
GET/api/records/{id}구조화된 출력으로 전체 레코드 상세 정보 가져오기
POST/api/records/batch-delete여러 레코드 삭제 (최대 100개)
POST/api/fusion/merge여러 model의 결과를 fusion합니다

첨부 파일

메서드엔드포인트설명
POST/api/attachments하나 이상의 파일을 업로드합니다(multipart/form-data)
POST/api/attachments/base64JSON base64로 파일 하나를 업로드합니다(multipart를 지원하지 않는 클라이언트용)
GET/api/attachments/{id}/download원본 파일 바이트를 다운로드합니다
DELETE/api/attachments/{id}첨부 파일 삭제 (강화 후 정리)

SSE 스트리밍

강화, 스키마 생성 및 융합 작업은 실시간 진행 상황을 위해 Server-Sent Events를 사용합니다. 작업을 시작하고 job_id를 받은 다음 SSE 스트림에 연결합니다:

SSE 이벤트 흐름

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"}

주요 이벤트 유형

이벤트설명
model_started모델 처리가 시작됩니다
expertise_completed전문 분야 하나 완료(부분 결과 포함)
model_completed모델이 result, record_id, cost와 함께 완료되었습니다
fusion_started / fusion_completed다중 모델 퓨전 수명 주기 이벤트
entity_started / entity_completed배치 전용 엔티티별 이벤트(entity_index 포함)
completed종료 이벤트 - 연결을 닫습니다
error작업 수준 오류가 발생했습니다

Python 예제

스키마를 나열하고, 강화를 시작하고, 결과를 스트리밍하고, 최종 레코드를 가져오는 완전한 워크플로:

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 예제

두 개의 모델로 배치 강화를 시작하고 결과를 스트리밍하세요:

# 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'

오류 처리

상태의미예시
200성공요청 완료
400잘못된 요청잘못된 모델 키 또는 누락된 필드
401권한 없음API 키가 없거나 잘못되었습니다
403금지됨이 엔드포인트에 대한 권한이 부족합니다
404찾을 수 없음레코드, 스키마 또는 작업을 찾을 수 없습니다
500서버 오류내부 오류

오류 응답에는 사람이 읽을 수 있는 오류 메시지가 담긴 detail 필드가 포함됩니다. 스트리밍 도중 문제가 발생하면 SSE 스트림은 최종 completed 이벤트 이전에 error 이벤트 유형을 발생시킵니다.

모델 복합 키

모델은 provider_name::model_name 형식의 복합 키로 식별됩니다. 사용 가능한 모델과 해당 키를 나열하려면 GET /api/enrichment/options를 사용하세요.

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

대화형 API 문서

애플리케이션에는 요청/응답 예시가 포함된 대화형 API 문서가 있습니다. 접근하려면 관리자 인증이 필요합니다:

다음 단계