API Reference
Base URL: http://localhost:8080 — All endpoints accept and return JSON.
Setup
Configure the LLM provider used for embeddings and entity extraction.
Request Body
- provider string required — LLM provider enum
- chatModelName string required — Chat model name
- embedModelName string required — Embedding model name
- apiKey string optional — API key for the provider
- baseUrl string optional — Custom base URL (e.g. Azure endpoint)
Example
curl -X POST http://localhost:8080/api/setup \
-H "Content-Type: application/json" \
-d '{
"provider": "GEMINI",
"chatModelName": "gemini-2.0-flash",
"embedModelName": "gemini-embedding-001",
"apiKey": "YOUR_API_KEY"
}'
Response — SetupResponse
{
"message": "LLM configured successfully",
"success": true,
"configuredProvider": "GEMINI",
"configuredChatModel": "gemini-2.0-flash",
"configuredEmbedModel": "gemini-embedding-001",
"timestamp": "2025-01-15T10:00:00Z"
}
Ingest
Ingest documents into CortexDB. The content is stored immediately, then processed asynchronously (chunking, embedding, entity/relation extraction).
Request Body
- uid string required — User identifier
- documentTitle string required — Title of the document
- documentText string required — Full text content to ingest
- metadata object optional — Arbitrary key-value metadata
Example
curl -X POST http://localhost:8080/api/v1/memory/ingest/document \
-H "Content-Type: application/json" \
-d '{
"uid": "user-1",
"documentTitle": "Memory Management in Java",
"documentText": "Java uses garbage collection for memory management."
}'
Response — IngestResponse
{
"knowledgeBase": {
"id": "a1b2c3d4-...",
"uid": "user-1",
"content": "Java uses garbage collection...",
"createdAt": "2025-01-15T10:00:00Z"
},
"status": "SUCCESS",
"message": "Document ingested successfully",
"processingTimeMs": 245,
"embeddingTimeMs": 120
}
Request Body
- uid string required — User identifier
- converser string required — Role:
USER,AGENT, orSYSTEM - text string required — Conversational text to ingest
- metadata object optional — Arbitrary key-value metadata
Example
curl -X POST http://localhost:8080/api/v1/memory/ingest/prompt \
-H "Content-Type: application/json" \
-d '{
"uid": "user-1",
"converser": "USER",
"text": "What is the capital of France?"
}'
Response — IngestResponse
{
"knowledgeBase": {
"id": "b2c3d4e5-...",
"uid": "user-1",
"content": "What is the capital of France?",
"createdAt": "2025-01-15T10:01:00Z"
},
"status": "SUCCESS",
"message": "Prompt ingested successfully",
"processingTimeMs": 150,
"embeddingTimeMs": 85
}
The response returns immediately. Chunking, embedding, entity extraction, and graph building happen asynchronously via PostgreSQL triggers.
Context Endpoints
Search and retrieve text chunks (contexts) created during document ingestion.
Request Body — QueryRequest
- query string required — Search text
- limit int optional — Max results (default: 5)
- minRelevance double optional — Min score 0–1 (default: 0.7)
- filters object optional — Metadata filters
Example
curl -X POST http://localhost:8080/api/v1/memory/query/contexts \
-H "Content-Type: application/json" \
-d '{"query": "memory management", "limit": 5, "minRelevance": 0.7}'
Path Parameters
- kbId UUID required — Knowledge base ID
curl http://localhost:8080/api/v1/memory/query/contexts/kb/a1b2c3d4-...
Query Parameters
- days int optional — Lookback period (default: 7)
curl "http://localhost:8080/api/v1/memory/query/contexts/recent?days=7"
Query Parameters
- startDate string required — ISO-8601 start date
- endDate string required — ISO-8601 end date
curl "http://localhost:8080/api/v1/memory/query/contexts/range?startDate=2025-01-01&endDate=2025-01-31"
Query Parameters
- days int optional — Lookback period (default: 7)
Request Body — QueryRequest
Same as POST /api/v1/memory/query/contexts.
curl -X POST "http://localhost:8080/api/v1/memory/query/contexts/recent?days=7" \
-H "Content-Type: application/json" \
-d '{"query": "memory", "limit": 5, "minRelevance": 0.7}'
Path Parameters
- contextId UUID required — Context ID
curl http://localhost:8080/api/v1/memory/query/contexts/siblings/c1d2e3f4-...
Entity Endpoints
Search the extracted entities (concepts, people, technologies, etc.) in the knowledge graph.
Request Body — QueryRequest
Same schema as context search.
curl -X POST http://localhost:8080/api/v1/memory/query/entities \
-H "Content-Type: application/json" \
-d '{"query": "Java programming", "limit": 5, "minRelevance": 0.7}'
Returns 404 if not found.
curl http://localhost:8080/api/v1/memory/query/entities/name/Java
Response — RagEntity
{
"id": "e1...",
"name": "Java",
"type": "Technology",
"description": "A programming language...",
"vectorEmbedding": [0.31, ...]
}
curl http://localhost:8080/api/v1/memory/query/entities/name-ignore-case/java
curl http://localhost:8080/api/v1/memory/query/entities/id/Java
Response
{ "id": "e1a2b3c4-..." }
Query Parameters
- entityName string required — Entity name to disambiguate
Request Body
Plain text (Content-Type: text/plain) providing context for disambiguation.
curl -X POST "http://localhost:8080/api/v1/memory/query/entities/disambiguate?entityName=Apple" \
-H "Content-Type: text/plain" \
-d "I was eating a fresh apple from the orchard"
curl http://localhost:8080/api/v1/memory/query/entities/e1a2b3c4-.../contexts
curl http://localhost:8080/api/v1/memory/query/contexts/c1d2e3f4-.../entities
Query Parameters
- sourceEntityId UUID required — Entity to merge from
- targetEntityId UUID required — Entity to merge into
curl -X POST "http://localhost:8080/api/v1/memory/query/entities/merge?sourceEntityId=e1...&targetEntityId=e2..."
This reassigns all context links and relations from the source entity to the target entity.
History Endpoints
Search and retrieve knowledge base entries (the raw ingested documents).
Request Body — QueryRequest
curl -X POST http://localhost:8080/api/v1/memory/query/history \
-H "Content-Type: application/json" \
-d '{"query": "Java memory", "limit": 5}'
curl http://localhost:8080/api/v1/memory/query/history/user/user-1
Query Parameters
- hours int optional — Lookback period (default: 24)
curl "http://localhost:8080/api/v1/memory/query/history/recent?hours=24"
Query Parameters
- since string required — ISO-8601 timestamp
curl "http://localhost:8080/api/v1/memory/query/history/since?since=2025-01-01T00:00:00Z"
User Data
Deletes all knowledge base entries, contexts, and associated data for the specified user.
curl -X DELETE http://localhost:8080/api/v1/memory/query/user/user-1
This permanently removes all data. Use for GDPR "Right to be Forgotten" compliance.
Graph Endpoints
Traverse the knowledge graph — explore entity relationships, find connections, and discover patterns.
What does this entity connect to? (e.g. Java → uses → GC)
curl http://localhost:8080/api/v1/memory/query/graph/outgoing/e1a2b3c4-...
What connects to this entity? (e.g. SpringBoot → uses → Java)
curl http://localhost:8080/api/v1/memory/query/graph/incoming/e1a2b3c4-...
"Friends of friends" — entities reachable in exactly 2 hops.
curl http://localhost:8080/api/v1/memory/query/graph/2hop/e1a2b3c4-...
Query Parameters
- limit int optional — Max results (default: 10)
curl "http://localhost:8080/api/v1/memory/query/graph/top?limit=10"
curl http://localhost:8080/api/v1/memory/query/graph/source/e1a2b3c4-...
Response — List<Relation>
[
{
"id": "r1...",
"sourceEntity": { "id": "e1...", "name": "Java" },
"targetEntity": { "id": "e2...", "name": "Garbage Collection" },
"relationType": "uses",
"edgeWeight": 3,
"createdAt": "2025-01-15T10:00:02Z"
}
]
curl http://localhost:8080/api/v1/memory/query/graph/target/e2b3c4d5-...
curl http://localhost:8080/api/v1/memory/query/graph/type/uses
Hybrid Search
Combines vector similarity search with graph-based context for richer results.
Request Body — QueryRequest
Same schema as context search.
curl -X POST http://localhost:8080/api/v1/memory/query/hybrid \
-H "Content-Type: application/json" \
-d '{"query": "How does Java handle memory?", "limit": 10, "minRelevance": 0.6}'
Query Routing
Automatically classify intent and route the query to the correct retrieval pipeline.
Request Body — QueryRequest
Same schema as context search.
curl -X POST http://localhost:8080/api/v1/memory/query/route \
-H "Content-Type: application/json" \
-d '{"query": "Summarize the document about Java memory.", "limit": 10}'
Request Schemas
QueryRequest
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
query |
string | ✅ | — | Search text |
limit |
int | — | 5 | Max results |
minRelevance |
double | — | 0.7 | Min similarity score (0–1) |
filters |
object | — | null | Metadata filters |
Response Schemas
QueryResponse
| Field | Type | Description |
|---|---|---|
query |
string | Original query text |
results |
SearchResult[] | Array of results |
processingTimeMs |
long | Total processing time |
SearchResult
| Field | Type | Description |
|---|---|---|
id |
UUID | Result ID |
content |
string | Text chunk or entity name |
score |
double | Similarity score |
type |
string | CHUNK, ENTITY, or RELATION |
metadata |
object | Additional metadata (JSONB) |
Enums
LLMApiProvider
| Value | Description |
|---|---|
GEMINI |
Google Gemini |
OPENAI |
OpenAI |
ANTHROPIC |
Anthropic Claude |
AZURE |
Azure OpenAI |
OPENROUTER |
OpenRouter (multi-provider gateway) |
ConverserRole
| Value | Description |
|---|---|
USER |
Content from a human user |
AGENT |
Content generated by AI |
SYSTEM |
System-level content |