Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DrDigett/Babel/llms.txt

Use this file to discover all available pages before exploring further.

The AI endpoints wrap Groq’s llama-3.1-8b-instant model for content classification. Both endpoints accept a free-text description of any content (book, film, article, course, video, or video game) and return a structured node object alongside suggested relations to nodes that already exist in your library. The key difference between the two endpoints is persistence: classify is read-only and never writes to the database, while smart-add classifies and immediately persists both the node and any matched relations in a single call.

POST /api/ai/classify

Classify free text and receive a suggested node with relation recommendations — without writing anything to the database. Use this endpoint to preview what the AI would create before committing.

Request body

text
string
required
Free-text description of the content to classify. The model extracts title, type, author, year, tags, and a short summary from this input. Maximum 10,000 characters.
typeHint
string
If provided, the model is instructed to use exactly this node type instead of inferring it. Must be one of: libro, pelicula, articulo, video, curso, videojuego.

Response

Returns 200 OK with a JSON object containing the classified node and suggested relations.
node
object
The AI-classified node structure.
relations
object[]
Suggested directed edges to nodes that already exist in the library.
curl -X POST http://localhost:3000/api/ai/classify \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Capital by Karl Marx, 1867. The foundational critique of capitalist political economy.",
    "typeHint": "libro"
  }'
{
  "node": {
    "title": "El Capital",
    "type": "libro",
    "description": "Crítica de la economía política capitalista.",
    "status": "pendiente",
    "priority": "media",
    "tags": ["marxismo", "economía", "capitalismo", "filosofía"],
    "author": "Karl Marx",
    "year": 1867,
    "link": null
  },
  "relations": [
    {
      "targetTitle": "Karl Marx",
      "type": "es_autor_de",
      "weight": 1.0
    },
    {
      "targetTitle": "Materialismo Histórico",
      "type": "trata_sobre",
      "weight": 0.7
    }
  ]
}

POST /api/ai/smart-add

Classify free text and immediately persist the resulting node and relations to the database in a single call. Relations are only created when the suggested targetTitle exactly matches an existing node’s title (case-insensitive comparison). Suggestions pointing to non-existent nodes are silently skipped.

Request body

Same as POST /api/ai/classify:
text
string
required
Free-text description of the content to classify and save. Maximum 10,000 characters.
typeHint
string
Optional node type override. One of: libro, pelicula, articulo, video, curso, videojuego.

Response

Returns 201 Created with the persisted node and the relations that were successfully created.
node
object
The persisted node object written to the database, including its generated UUID, createdAt, updatedAt, and all database fields (e.g., localFile). Note that tags is serialized as a JSON string (e.g., "[\"marxismo\",\"economía\"]") or null — not an array.
relations
object[]
Array of CreatedRelation objects for each relation that was matched and written to the database.
curl -X POST http://localhost:3000/api/ai/smart-add \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Capital by Karl Marx, 1867. The foundational critique of capitalist political economy, analyzing commodity, value, surplus value, and capital accumulation.",
    "typeHint": "libro"
  }'
{
  "node": {
    "id": "new-uuid",
    "title": "El Capital",
    "type": "libro",
    "description": "Crítica de la economía política capitalista.",
    "status": "pendiente",
    "priority": "media",
    "tags": "[\"marxismo\",\"economía\",\"capitalismo\"]",
    "author": "Karl Marx",
    "year": 1867,
    "link": null,
    "localFile": null,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  },
  "relations": [
    {
      "id": "relation-uuid",
      "sourceId": "new-uuid",
      "targetId": "existing-marx-uuid",
      "type": "es_autor_de",
      "weight": 1.0,
      "createdAt": "2024-01-15T10:30:00.000Z",
      "targetTitle": "Karl Marx"
    }
  ]
}

Error responses

StatusCondition
400text is missing, empty, or exceeds 10,000 characters
500The Groq API returned an error or the model response could not be parsed as valid JSON
smart-add does not deduplicate. Calling it twice with the same input creates two separate nodes with identical content. Use POST /api/ai/classify first to preview the result, then call smart-add only when you are ready to persist — or search for the node with GET /api/search before adding to avoid duplicates.

Build docs developers (and LLMs) love