What is the error code returned by API call

https://platform.openai.com/docs/guides/error-codes/api-errors

The error code above does not match the error code returned by the actual curl call. I need the real error code

{
    "error": {
        "message": "The model `gpt-5213` does not exist or you do not have access to it.",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}
{
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
    }
}

The error code is status 429 for the “check your plan” lack of funds, and Status Code: 400 for a nonexistent model.

If you’re wondering how to get the HTTP status code from an API request, you don’t offer much in telling us why you are unable.

Here’s Python using the OpenAI library, and the Responses endpoint to chat. Just need to make an error:

from openai import OpenAI
import json
client = OpenAI()  # send it api_key="badKey"...
error=None
try:
    response = client.responses.create(
        model="gpt-4.1-extreme",
        instructions=("You are Bob, a helpful AI."),
        input=[
            {
                "role": "user",
                "content": "Got any errors to report?",
            }
        ],
        max_output_tokens=30,
        store=False,
    )
    for output in response.output:
        # prints raw event-like objects
        print(output.model_dump(), "\n-----")
except Exception as e:
    error=e
    print(f"ERROR: Status Code: {error.status_code}")
    print(f"ERROR: Server response: {error.response}")
    print(f"ERROR: Server message: {error.body}")

Delivering:

ERROR: Status Code: 400
ERROR: Server response: <Response [400 Bad Request]>
ERROR: Server message: {'message': "The requested model 'gpt-4.1-extreme' does not exist.", 'type': 'invalid_request_error', 'param': 'model', 'code': 'model_not_found'}

I know my account balance is insufficient. I’m accessing through the API. I need to know all the error types in order to adapt our system accordingly.

CURL is showing you the HTTP body that is also returned by the API upon error for better understanding.

Getting an error status to also be printed (by a typical API reference example), here’s the --write-out flag with a CURL value for the status code:

curl -s -w "\n%{http_code}\n" https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-5-mini",
    "messages": [
      { "role": "developer", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Hello!" }
    ]
  }'

You will find very quickly that you want to write in a programming language instead of CURL command lines. Then they have their own methods for making http API calls and getting results, or if using the OpenAI-provided SDK libraries, a unique error type for each situation and code (as seen in your link).