REST API Reference
If you are not using our TypeScript or Python SDKs, you can interact directly with our Edge Engine using standard HTTP REST requests.
All requests must include your API key in the Authorization header as a Bearer token.
1. Ingest Memory
Store a new piece of context.
- Endpoint:
POST https://libro.co.in/api/v1/ingest - Headers:
Authorization: Bearer YOUR_API_KEYContent-Type: application/json
Request Payload
{
"userId": "string (required)",
"content": "string (required) - The text to vectorize.",
"metadata": { "key": "value" } // optional JSON object
}
Response 200 OK
{
"success": true,
"memory": {
"id": "uuid",
"content": "string"
}
}
2. Get Context
Retrieve an optimized string of semantics formatted for an LLM prompt.
- Endpoint:
POST https://libro.co.in/api/v1/context - Headers:
Authorization: Bearer YOUR_API_KEY
Request Payload
{
"userId": "string (required)",
"query": "string (required) - The semantic question."
}
Response 200 OK
{
"success": true,
"context": "string (Formatted results separated by newlines)"
}
3. Semantic Search
Return raw arrays of memory objects with their cosine similarity scores.
- Endpoint:
POST https://libro.co.in/api/v1/search - Headers:
Authorization: Bearer YOUR_API_KEY
Request Payload
{
"userId": "string (required)",
"query": "string (required)",
"limit": 5, // optional
"filter": { "priority": "high" } // optional metadata filter
}
Response 200 OK
{
"success": true,
"results": [
{
"id": "uuid",
"content": "string",
"score": 0.89,
"metadata": {}
}
]
}
4. Agent Segregation (Namespaces)
If you are building multiple agents (e.g. a "Coding Agent" and a "Support Agent") under the same Libro project, you must ensure their memories do not leak into each other.
Libro provides an elegant way to segregate memories using Implicit Metadata Filtering. You do not need to create separate projects or API keys.
1. Ingesting with a Namespace
Simply pass a namespace (or any arbitrary key) in the metadata payload during ingestion:
await fetch('https://libro.co.in/api/v1/ingest', {
method: 'POST',
headers: {
'Authorization': 'Bearer libro_sk_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: "The main server IP is 10.0.0.5",
metadata: {
namespace: "coding-agent",
project: "backend"
}
})
});
2. Searching within a Namespace
When you retrieve context, simply pass the exact same metadata payload back. Libro will pre-filter the vector index to ensure the semantic search only runs over memories matching that namespace!
await fetch('https://libro.co.in/api/v1/get-context', {
method: 'POST',
headers: {
'Authorization': 'Bearer libro_sk_...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: "What is the server IP?",
metadata: {
namespace: "coding-agent"
}
})
});
This pattern can be extended to segregate by session_id, customer_id, or tenant_id effortlessly.