The HTTP Response will have the same status code as error.code, forming a request error if:
Your original request is invalid
Your API key/account is out of credits
Otherwise, the returned HTTP response status will be200 and any error that occurs while the LLM is producing output will be emitted in the response body or as an SSE data event.Example code for printing errors in JavaScript:
Copy
const request = await fetch('https://api.anannas.ai/v1/chat/completions', { method: "POST", headers: { "Authorization": `Bearer ${process.env.ANANNAS_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ model: "openai/gpt-4o", messages: [{ role: "user", content: "Hello world" }] })});console.log(request.status); // Will be an error code unless the model started processingconst response = await request.json();console.error(response.error?.code);console.error(response.error?.message);