Query Knowledge Search and traverse the knowledge graph for entities and relationships.
Query Cerebe's Knowledge Graph to find entities, relationships, and facts. Supports natural language queries with configurable traversal depth and filtering.
POST /api/v1/knowledge/query
Parameter Type Required Description querystringYes Natural language or structured query entity_idstringNo Starting entity for graph traversal entity_typestringNo Filter results by entity type relationship_typesstring[]No Filter by specific relationship types depthintegerNo Maximum traversal depth, 1-5 (default: 2) limitintegerNo Maximum results, 1-100 (default: 20)
Python TypeScript curl
from cerebe import AsyncCerebe
client = AsyncCerebe( api_key = "ck_live_..." )
results = await client.knowledge.query(
query = "Who does Alice mentor?" ,
depth = 2 ,
limit = 10 ,
)
for entity in results.entities:
print ( f " { entity.name } ( { entity.entity_type } )" )
for rel in results.relationships:
print ( f " { rel.source_id } --[ { rel.relationship_type } ]--> { rel.target_id } " ) import Cerebe from '@cerebe/sdk'
const client = new Cerebe ({ apiKey: 'ck_live_...' })
const results = await client.knowledge. query ({
query: 'Who does Alice mentor?' ,
depth: 2 ,
limit: 10 ,
})
for ( const entity of results.entities) {
console. log ( `${ entity . name } (${ entity . entityType })` )
}
for ( const rel of results.relationships) {
console. log ( `${ rel . sourceId } --[${ rel . relationshipType }]--> ${ rel . targetId }` )
} curl -X POST https://api.cerebe.ai/api/v1/knowledge/query \
-H "X-API-Key: ck_live_..." \
-H "Content-Type: application/json" \
-d '{
"query": "Who does Alice mentor?",
"depth": 2,
"limit": 10
}'
{
"entities" : [
{
"id" : "ent_abc123" ,
"name" : "Alice mentors Bob" ,
"entity_type" : "fact" ,
"properties" : null ,
"created_at" : "2025-03-07T14:30:00Z"
}
],
"relationships" : [],
"total" : 1
}
Field Type Description idstringUnique entity identifier namestringEntity name or fact description entity_typestringType classification (e.g., person, organization, fact) propertiesobjectAdditional entity properties created_atstringISO-8601 creation timestamp
Field Type Description source_idstringSource entity ID target_idstringTarget entity ID relationship_typestringType of relationship propertiesobjectRelationship properties valid_fromstringWhen this relationship became true valid_tostringWhen this relationship ended (null if still active)
The knowledge graph is temporal --- relationships have valid_from and valid_to fields. This enables point-in-time queries:
# Who was on the team in January?
results = await client.knowledge.query(
query = "team members" ,
entity_id = "team_alpha" ,
depth = 1 ,
)
Status Description 401Missing or invalid API key 503Knowledge graph service unavailable