Error reference

OpenAI billing and quota errors

The answers OpenAI gives when an organization cannot pay for a request, and the ones that look similar but are not about money. For each: the status, the body, and what keyover does with it.

Rejections about money or the key

429Prepaid credit balance is depleted

Moves to the next key: out of credit

{
  "error": {
    "type": "insufficient_quota",
    "code": "credit_balance_exhausted"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

429You exceeded your current quota, please check your plan and billing details

Moves to the next key: out of credit

The long-standing form. The reference now names the cause in error.code and keeps insufficient_quota as the broader error.type.

{
  "error": {
    "message": "You exceeded your current quota, please check your plan and billing details.",
    "type": "insufficient_quota",
    "param": null,
    "code": "insufficient_quota"
  }
}

Reported in the field: stackoverflow.com. The body shows the fields the source establishes.

429Organization reached the monthly spend limit it set

Moves to the next key: your own spend limit

{
  "error": {
    "type": "insufficient_quota",
    "code": "organization_spend_limit_exceeded"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

429Project reached the monthly spend limit it set

Moves to the next key: your own spend limit

{
  "error": {
    "type": "insufficient_quota",
    "code": "project_spend_limit_exceeded"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

400Billing hard limit has been reached

Moves to the next key: your own spend limit

A legacy code, reported on image and batch endpoints. It is not in the current reference.

{
  "error": {
    "code": "billing_hard_limit_reached",
    "message": "Billing hard limit has been reached",
    "param": null,
    "type": "invalid_request_error"
  }
}

Reported in the field: community.openai.com. The body shows the fields the source establishes.

429Organization reached the monthly usage limit OpenAI assigned

Stays by default: a cap the provider assigned

OpenAI assigns this limit. The pool does not move a request for it unless failoverOn includes provider_limit.

{
  "error": {
    "type": "insufficient_quota",
    "code": "organization_usage_limit_exceeded"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

401Incorrect API key provided

Moves to the next key: key not accepted

The reference documents the 401 and its causes: a wrong, revoked or deleted key. The code is what the response carries.

{
  "error": {
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

Reported in the field: community.openai.com. The body shows the fields the source establishes.

Answers that are not a reason to change key

401IP not authorized

Stays with your SDK

The organization's own IP allowlist. An access restriction is never routed around.

{
  "error": {
    "message": "IP not authorized"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

401You must be a member of an organization to use the API

Stays with your SDK

A membership decision, not a key that is unknown.

{
  "error": {
    "message": "You must be a member of an organization to use the API"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

429A quota code this version does not know

Stays with your SDK

The reference says to read the code. A new one may be a cap, so it passes until it is listed.

{
  "error": {
    "type": "insufficient_quota",
    "code": "a_code_added_later"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

429Rate limit reached for requests

Stays with your SDK

A traffic control. Your SDK retries it.

{
  "error": {
    "message": "Rate limit reached for requests"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

429Request rate increased too quickly

Stays with your SDK

A traffic control. Your SDK retries it.

{
  "error": {
    "type": "rate_limit_error",
    "code": "slow_down"
  }
}

Documented by OpenAI: developers.openai.com. The body shows the fields the source establishes.

403Country, region, or territory not supported

Stays with your SDK

An access restriction. Never routed around.

Documented by OpenAI: developers.openai.com

Keep serving through it

Give the pool a second key that bills another organization you are authorized to use. When OpenAI refuses the first for one of the rejections above, the same request is sent again on the second, inside the same call. Your code gets a normal response, and an event tells you which organization needs attention.

import OpenAI from "openai"
import { createKeyPool, OPENAI } from "keyover"

const pool = createKeyPool({
  provider: OPENAI,
  keys: {
    primary: process.env.OPENAI_API_KEY,
    spare: process.env.OPENAI_API_KEY_SPARE,
  },
})

const openai = new OpenAI(pool.clientOptions)

const response = await openai.responses.create({ model: "gpt-6-luna", input: "Say hello." })
console.log(response.output_text)

See it fail over in the playground, or read the README.