Developers Errors and limits

Errors and limits.

What can go wrong, and what to do about it.

Errors

Always {"error":{"message","type","code"}} with a matching HTTP status. Quote the x-request-id response header in bug reports.

JSON
{ "error": { "message": "The model \"nova\" does not exist or you do not have access to it.", "type": "invalid_request_error", "code": "model_not_found" } }
StatusCodeTypeMeaning
400invalid_json, invalid_messages, invalid_parameter, invalid_tools, unsupported_content, system_too_long, context_length_exceededinvalid_request_errorThe request is malformed or too big.
401missing_credentials, invalid_credentials, invalid_api_key, api_key_revoked, api_key_expired, invalid_tokenauthentication_errorNo credential, or a bad one.
403insufficient_scope, origin_not_allowed, no_plan, no_models, blocked_by_permissionspermission_errorNot allowed.
404model_not_found, not_foundinvalid_request_errorUnknown model (also when it exists but you may not use it) or endpoint.
405method_not_allowedinvalid_request_errorWrong HTTP method.
413request_too_largeinvalid_request_errorBody over 256 KB.
429rate_limit_exceededrate_limit_errorToo many requests a minute. Retry-After says when.
429daily_cap_exceeded, monthly_cap_exceededinsufficient_quotaA service key's token cap is used up. Retry-After runs to the next UTC day or month.
429limit_day, limit_weekinsufficient_quotaThe person's plan allowance is used up. Retry-After runs to the reset.
502upstream_error, empty_responseserver_errorThe model failed. Details are never shown.
503api_disabledserver_errorThe API is switched off for now. Retry-After: 300.
503model_starting, model_unavailableserver_errorThe model is waking up or briefly unavailable. Retry after Retry-After.

What to retry

Retry 429 (after Retry-After) and 503. Do not retry other 4xx errors: fix the request. The example waits for retryAfter seconds and gives up after three attempts:

JavaScript
import { createClient, ArtemiiError } from './artemii.js';

const ai = createClient({ baseUrl: 'https://mayfair-ai.crelloo.workers.dev', apiKey: process.env.ARTEMII_KEY });

async function ask(messages) {
  for (let attempt = 0; attempt < 3; attempt++) {
    try {
      return await ai.chat({ model: 'arlo', messages });
    } catch (err) {
      if (!(err instanceof ArtemiiError)) throw err;
      const retryable = err.status === 429 || err.status === 503; // see Errors and limits
      if (!retryable || attempt === 2) {
        console.error(err.status, err.code, err.message, 'request id:', err.requestId);
        throw err;
      }
      await new Promise((resolve) => setTimeout(resolve, (err.retryAfter ?? 2) * 1000));
    }
  }
}

const reply = await ask([{ role: 'user', content: 'Hello' }]);
console.log(reply.choices[0].message.content);

Limits

LimitValue
Requests a minuteA token bucket per key (burst equal to its limit) or per person (30 a minute by default). See the x-ratelimit-* headers.
Token caps (service keys)A daily and a monthly cap (UTC), always set. Checked before the call (refused when the estimated prompt alone would exceed what is left, and the answer is clamped to the room that remains) and counted after it. Calls already in flight can overshoot by their own size.
Plan allowance (people)The same daily and weekly windows as the Artemii app, checked before the call and counted after it.
Request body256 KB
Messages200 per request
Your system text16,000 characters
Whole conversation200,000 characters
Outputmax_tokens defaults to 4096 and is clamped to 8000
Waiting for a sleeping modelStreamed: up to 8 minutes. Not streamed: a limit set by the gateway, then 503 model_starting.

Kill switch and revoking

Mayfair can switch the API off; every /v1 call then answers 503 api_disabled while the Artemii app keeps working. Revoking a key takes effect on its next request. Expired keys stop at their expiry.