AI API
POST /api/v1/ai/ask is an application endpoint that runs one Coffee AI turn and returns a single JSON document. It is not currently exposed as a general third-party OAuth capability. For external integrations, use the authorized tools listed by MCP or the integration reference; do not reuse a browser session token. The behavior below describes clients that already have supported access.
Long-running turns
A turn can take up to about 15 minutes when it runs tools. While it runs, Coffee keeps the connection open by sending whitespace. Parse the body only once the response completes, and set your client timeout to at least 16 minutes.
Request basics
| Field | Required | Notes |
|---|---|---|
chat_type | yes | The surface, for example assistant, task, meeting, project, note. |
client_turn_id | yes | Your ID for this submit. Echoed back so concurrent turns do not mix. |
agent_mode | no | plan or act. |
module_hash | no | The item the turn is about. |
agent_id | no | Run the turn as a specific agent. |
Retries
The endpoint supports idempotent retries. Send an Idempotency-Key header, and reuse the same value when you retry a failed request, so the turn runs once.