Clatter LabsHelp Center

How do I send a long prompt with cURL without quoting problems?

How-toUpdated

Shell quoting breaks easily with quotes and newlines in a prompt. Put the body in a file instead.

cat > body.json <<'EOF'
{
  "model": "supercosmos-max",
  "messages": [
    {"role": "system", "content": "You review code. Be specific."},
    {"role": "user", "content": "Review this:\n\ndef add(a, b):\n    return a - b"}
  ]
}
EOF

curl 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 @body.json

If you still see 400 invalid_json, run jq . body.json to find the broken spot.

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
  • Keep keys on your server, never in a browser or mobile app. Why
  • 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.