Clatter LabsHelp Center

How do I stream with cURL?

How-toUpdated

Use -N (no buffering) and "stream": true. Each event is a data: line, ending with data: [DONE].

curl -N https://api.gateway.clatterlabs.xyz/v1/chat/completions \
  -H "Authorization: Bearer $CLATTER_API_KEY" \
  -H "X-Clatter-Account: $CLATTER_ACCOUNT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "supercosmos-flash",
    "stream": true,
    "stream_options": {"include_usage": true},
    "messages": [{"role": "user", "content": "Count to five."}]
  }'

Without -N, cURL may hold output until the end and it looks like streaming doesn't work.

Set CLATTER_API_KEY (a clsk_ key with models:invoke) and CLATTER_ACCOUNT_ID (your CL- Account ID from Console › Settings) first. Reference: Model API reference.

Good to know#

  • Every response has an X-Request-Id; log it so a request can be found later. Why log it
  • If calls fail unexpectedly, check status.clatterlabs.com before debugging further.
  • Retry only 429 and 5xx errors, with backoff; honour Retry-After when it's sent. Which errors to retry

Still need help?#

We usually reply within the first hour, and always within 24 hours. A full support team is with you.

Related articles

Still need help?

Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.

Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyz
For deleting your whole account or the data of one service.