Chloe

Docs

HTTP

Opening an agent to another system: one POST, one turn, one reply, with a token.


For another system rather than a person: one POST, one turn, one reply.

  1. Add the channel to the agent:
// This agent may be reached by another system holding a token.
//
// Without this file, POST /api/agents/shop/chat is refused for a token and
// answered only for somebody signed in on the box.
import { apiChannel } from "@chloejs/core/channels";

export default apiChannel();
  1. Make a token, with npx chloe tokens make <name> or on the dashboard's tokens page. The secret is shown once and not stored.
  2. Call the agent:
curl -X POST http://127.0.0.1:3067/api/agents/shop/chat \
  -H "authorization: Bearer $CHLOE_TOKEN" \
  -H "content-type: application/json" \
  -d '{"prompt":"how many orders are late?"}'

{"runId":"...","text":"Three are late.","steps":2,"cost":0.0031}
curl -X POST http://127.0.0.1:3067/api/agents/shop/job/restock \
  -H "authorization: Bearer $CHLOE_TOKEN"

{"started":"shop/restock"}

Send thread, a name of your own, to carry on a conversation; leave it out to start fresh. Send timeZone, the writer's, like "Europe/Madrid", for the model to be told their date rather than the server's. A second message on a thread while its reply is going joins that reply, and answers at once with "joined": true and no text: the first call's reply answers both. POST /api/agents/shop/chat/stop with the same thread stops the reply, and the first call answers Stopped. Without this channel a token gets a 403 for that agent, and only somebody signed in on the dashboard can reach it. It takes chatHistory and nothing else. A job that stops to ask somebody waits in GET /api/parked, because HTTP cannot push a question out. A reply that asks them to pick carries buttons and multiple (Asking a person).