Can I call the Model API with plain fetch instead of the SDK?
Yes. Any HTTP client works. This is the whole request with fetch (Node 18+, Deno, Bun).
const res = await fetch("https://api.gateway.clatterlabs.xyz/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CLATTER_API_KEY}`,
"X-Clatter-Account": process.env.CLATTER_ACCOUNT_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "supercosmos-flash",
messages: [{ role: "user", content: "Hello!" }],
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error?.code}: ${data.error?.message}`);
console.log(data.choices[0].message.content, res.headers.get("x-request-id"));
Every JavaScript example uses the same client (base URL, key and the X-Clatter-Account header); see Set up the JavaScript SDK. Full parameter list: Create a chat completion.
Good to know#
- Retry only
429and 5xx errors, with backoff; honourRetry-Afterwhen it's sent. Which errors to retry - Every call shows in Console › Logs and Usage as Model API, with its price. See what you spent
- Keep keys on your server, never in a browser or mobile app. Why
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
- How do I set up the OpenAI JavaScript SDK for the Model API?
- Can I use the Model API from Deno or Bun?
- How do I read response headers like X-Request-Id in JavaScript?
- How do I call the Model API with Python's requests library?
- Can I use the Model API instead of Line CLI?Line CLI
- How do I try SuperCosmos?SuperCosmos models
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.