cloadyDocs
API ReferenceEndpointsWorkspaces

Chat with a model

Send a conversation to a model through the gateway, as the AI tool's chat does (developer role). It is free while the caller's account is within its AI allowance (60 answers an hour, shared with Ask AI) and the request's worst case costs at most $0.25 (output is capped to fit), and charged to the caller's usage balance otherwise; with `keyId` the key's models, budget and rate limit apply. With `Accept: text/event-stream` the reply streams as a `start` event naming the model and provider that answer (`fallback` when an alias moved on), then `delta` events (`{type, text}`), and ends with a `done` event carrying the usage, or an `error` event; otherwise it answers once with the whole reply.

POST
/api/workspaces/{workspaceSlug}/ai/chat
AuthorizationBearer <token>

Personal API token (cldy_…)

In: header

Path Parameters

workspaceSlug*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/workspaces/string/ai/chat" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "messages": [      {        "role": "user",        "content": "string"      }    ]  }'
{  "text": "string",  "usage": {    "model": "string",    "provider": "string",    "input": 0,    "output": 0,    "micros": 0,    "charged": 0,    "ms": 0  }}