API Reference

Errors & Status Codes Reference

Cortiqa returns conventional HTTP status codes and structured JSON error objects to assist with automated retry logic and debugging.


HTTP Status Codes

CodeStatusDescription
200OKThe request succeeded.
400Bad RequestMalformed JSON, missing required parameters, or invalid model ID.
401UnauthorizedMissing, expired, or invalid sk-cortiqa-... API key.
403ForbiddenYour account or key lacks permissions for the requested resource.
404Not FoundThe requested file, batch ID, or endpoint does not exist.
429Too Many RequestsRate limit exceeded or account monthly budget hard cap reached.
500Internal Server ErrorAn unexpected server error occurred. Automatic SDK retries will attempt recovery.
503Service UnavailableHigh cluster concurrency or scheduled maintenance. Retry with backoff.

Error Payload Schema

When an error occurs, the response body contains a JSON object with error metadata:

HTTP 401 Response
{
  "error": {
    "message": "Incorrect API key provided: sk-cortiqa-***. You can obtain your API key from https://platform.cortiqa.co/api-keys.",
    "type": "authentication_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

Handling Typed SDK Exceptions

Catch typed exceptions natively in your code:

python_errors.py
# Python
from cortiqa import Cortiqa
from cortiqa.exceptions import AuthenticationError, RateLimitError, APIError

client = Cortiqa()

try:
    response = client.chat.completions.create(
        model="openai/gpt-oss-120b",
        messages=[{"role": "user", "content": "Hello"}]
    )
except AuthenticationError:
    print("Invalid API key! Check sk-cortiqa credentials.")
except RateLimitError:
    print("Rate limit reached! Backing off...")
except APIError as e:
    print(f"API returned status {e.status_code}: {e.message}")
ts_errors.ts
// TypeScript / Node.js
import Cortiqa, { AuthenticationError, RateLimitError, APIError } from "@cortiqa/sdk";

const client = new Cortiqa();

try {
  const message = await client.messages.create({
    model: "openai/gpt-oss-120b",
    messages: [{ role: "user", content: "Hello" }],
  });
} catch (err) {
  if (err instanceof AuthenticationError) {
    console.error("Invalid API key!");
  } else if (err instanceof RateLimitError) {
    console.error("Rate limit exceeded!");
  } else if (err instanceof APIError) {
    console.error(`Cortiqa API error ${err.status}: ${err.message}`);
  }
}
Was this page helpful?