How do I set retries and timeouts in the JavaScript SDK?
The client retries rate limits and server errors with backoff. Adjust it globally or per call.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.gateway.clatterlabs.xyz/v1",
apiKey: process.env.CLATTER_API_KEY,
defaultHeaders: { "X-Clatter-Account": process.env.CLATTER_ACCOUNT_ID },
maxRetries: 4,
timeout: 120_000,
});
await client.chat.completions.create(
{ model: "supercosmos-heavy", messages },
{ timeout: 300_000 },
);
For long Heavy answers, prefer streaming so the connection carries tokens as they're produced.
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#
- Every call shows in Console › Logs and Usage as Model API, with its price. See what you spent
- New accounts get $5 of free credit; top up from $1 to $800 per purchase in Console › Billing › Credits. Billing
- Your key's account is responsible for your end users' text under the Abuse policy. What it means for apps
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.