With your API key, your system talks to its agent just like you do in Qaalia Chat: the agent uses its systems(on the internet, on your machine or MCP) with each operation's permission, works with files, searches the web and, if the job is large, continues it as a background task. Your system doesn't declare or run anything: it just sends the message.
Endpoint
POST https://csevfgnqeweymrgebayc.supabase.co/functions/v1/agent-chatAuthorization: Bearer <TU_API_KEY>Content-Type: application/jsonCreate your API key in API keys. The model isn't sent: Qaalia uses the one you configured on the agent.
curl -X POST "https://csevfgnqeweymrgebayc.supabase.co/functions/v1/agent-chat" \ -H "Authorization: Bearer $QAALIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mensaje": "Hola, ¿qué puedes hacer por mí?" }'Request body
adjuntos.user_id.[{ "ruta_storage": "…" }]. See Attachments.["generar-pdf"]). It's the same as writing /generar-pdf in the message.truereturns the response as it's generated (Server-Sent Events). Without it, you get a single JSON when it finishes.Response
Without stream, Qaalia responds with one of these three types:
- respuesta: the agent finished and replies.
{ "exito": true, "tipo": "respuesta", "respuesta": "¡Hola! Puedo responder dudas sobre tu negocio y ejecutar acciones en tu sistema.", "conversation_id": "7d1f3c2a-9b4e-4f6a-8c1d-2e5b6a7f9c30"}If a skill generated files, the response includes archivos: each with nombre, url (valid for 7 days), mime and bytes.
- tarea: the job is large and continues in the background (for example, registering hundreds of rows). Check its progress with Long tasks.
{ "exito": true, "tipo": "tarea", "task_id": "3b9e0c1d-5a7f-4e2b-9c8d-1f0a2b3c4d5e", "titulo": "Registrar 480 estudiantes", "conversation_id": "7d1f3c2a-9b4e-4f6a-8c1d-2e5b6a7f9c30"}- pregunta: the agent needs some information before continuing. Reply in the next
mensajewith the sameconversation_id.
{ "exito": true, "tipo": "pregunta", "preguntas": [{ "pregunta": "¿En qué curso los registro?", "encabezado": "Curso", "opciones": [{ "etiqueta": "Química" }, { "etiqueta": "Física" }] }], "respuesta": "", "conversation_id": "7d1f3c2a-9b4e-4f6a-8c1d-2e5b6a7f9c30"}Systems and permissions
The agent works with its systems' operations according to the permission you gave them in Qaalia Chat → Systems: allowed ones run, the ones that ask for approval wait for you (the owner) to approve them in Qaalia Chat, and the agent doesn't even know about blocked ones. Your systems' credentials never travel in the request or reach the model.
Long tasks
When the response is of type tarea, Qaalia keeps running it even if your system disconnects: it advances in stretches, saves its progress and never runs the same action twice. Check its status and its events (use despues with the last id received to fetch only the new ones):
curl -X POST "https://csevfgnqeweymrgebayc.supabase.co/functions/v1/agent-chat" \ -H "Authorization: Bearer $QAALIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "consultar_tarea": "3b9e0c1d-5a7f-4e2b-9c8d-1f0a2b3c4d5e", "despues": 0 }'The response includes status (queued, running, completed, failed, cancelled), progreso, eventos and, when it finishes, respuesta. To stop it send { "cancelar_tarea": "<task_id>" }.
Streaming
With stream: true you receive the same events Qaalia Chat sees, each one as data: {…}:
const respuesta = await fetch("https://csevfgnqeweymrgebayc.supabase.co/functions/v1/agent-chat", { method: "POST", headers: { Authorization: `Bearer ${process.env.QAALIA_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ mensaje: "Registra los clientes del archivo", stream: true }),})const lector = respuesta.body.getReader()const decodificador = new TextDecoder()let pendiente = ""while (true) { const { done, value } = await lector.read() if (done) break pendiente += decodificador.decode(value, { stream: true }) const bloques = pendiente.split("\n\n") pendiente = bloques.pop() for (const bloque of bloques) { if (!bloque.startsWith("data:")) continue // ": ping" mantiene viva la conexión const e = JSON.parse(bloque.slice(5)) if (e.event === "text_delta") process.stdout.write(e.delta) if (e.event === "task_started") console.log("\nTarea en segundo plano:", e.task_id) if (e.event === "chat_end") console.log("\nconversation_id:", e.conversation_id) }}Errors
Errors respond with { "exito": false, "error": "…" } and an HTTP code:
Every error is recorded in your logs with its cause.
Limits
- Model: usage is billed by your AI provider (BYOK); Qaalia doesn't limit its tokens. Messages are unlimited.
- Operations: the ones your plan allows per agent, spread across its systems.
- Long tasks: one at a time per conversation.

