Azzouz

API reference · OpenAI

Understand the API before you ship.

A focused overview of API surfaces, authentication, request headers, debugging identifiers, compatibility, and production-readiness checks.

Start here

Choose the API surface for your application.

Authentication

Keep credentials on the server.

Use a standard API key for application requests, an Admin API key for administration endpoints, or a short-lived access token created through workload identity federation. Never expose a key in browser code or a public application bundle.

Authorization: Bearer OPENAI_API_KEY_OR_ACCESS_TOKEN

Request headers

Leave room for required metadata.

Keep the total request-header size under 64 KiB. To leave room for required headers and intermediaries, keep custom header values and the combined custom-header budget at 60 KiB or less.

Common headers

Authorization, Content-Type, User-Agent, and any organization or project selectors.

Organization context

Use OpenAI-Organization and OpenAI-Project when your request needs explicit context.

Debugging requests

Log request IDs and rate-limit signals.

Inspect response headers for the server-generated x-request-id, processing time, API version, and rate-limit details. Official client libraries expose the request ID on top-level response objects.

x-request-idUnique server request identifier.
openai-processing-msProcessing time for the request.
x-ratelimit-*Limits, remaining capacity, and reset times.

Client request IDs

You may send X-Client-Request-Id with a unique ASCII identifier up to 512 characters. This is useful when a timeout prevents you from receiving the server-generated request ID.

curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "X-Client-Request-Id: 123e4567-e89b-12d3-a456-426614174000"

Backwards compatibility

Expect additive API changes, not fixed model behavior.

The REST API remains on the v1 major version and official libraries follow semantic versioning. Additive resources, optional parameters, properties, event types, and opaque identifier changes are considered backwards-compatible. Model prompting behavior between snapshots can still change.

Pin modelsUse pinned versions when consistent behavior matters.
Run evalsMeasure changes before promoting updates.
Review limitsPlan for errors, rate limits, and request logging.
Open the changelog ↗