How do I print only the text of a streamed reply with cURL?
curl -sN 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, "messages": [{"role": "user", "content": "Count to ten."}]}' \
| sed -un 's/^data: //p' | grep --line-buffered -v '^\[DONE\]$' \
| jq -j --unbuffered '.choices[0].delta.content // (.error | tostring) // empty'
echo
Errors inside the stream print instead of being silently skipped.
Good to know#
- Each key has its own limit: 10, 30 (default), 60 or 120 requests per minute. Rate limits
- Your key's account is responsible for your end users' text under the Abuse policy. What it means for apps
- Every call shows in Console › Logs and Usage as Model API, with its price. See what you spent
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
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.xyzFor deleting your whole account or the data of one service.