All insights

Model APIs

GPT-5 API: Make Your First OpenAI Responses API Request

Connect to GPT-5.5 through OpenAI’s API, make a first Responses API request, check for completed output, and add schema-constrained data to an application.

Illustration for Gpt 5 api

As of November 8, 2026, OpenAI’s API documentation lists GPT-5.5 and the snapshot gpt-5.5-2026-04-23. The model supports the Responses API at https://api.openai.com/v1/responses and Structured Outputs. Use the alias for the documented model or the snapshot when you need a fixed version. (GPT-5.5 model documentation)

Make a first GPT-5 API request

Before sending a request:

  1. Select an API project and create or obtain an API key that has access to it. Project roles and settings control access to keys, models, and usage. (Managing API projects)
  2. Set the key in your terminal instead of putting the secret in your code or request body. For macOS or Linux:
export OPENAI_API_KEY="your-api-key"
  1. Check that the selected project has access to the model and an API billing arrangement. API billing is separate from ChatGPT billing; available payment and credit arrangements depend on the account. (API billing)

Send a short request with curl:

curl -sS -w '\nHTTP %{http_code}\n' https://api.openai.com/v1/responses \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "input": "Reply with exactly: API connected."
  }'

The endpoint, Bearer authentication, and JSON request pattern follow OpenAI’s API quickstart; the GPT-5.5 model page lists Responses as a supported endpoint. (OpenAI API documentation)

Check that the response completed before using its text. A successful HTTP response alone does not show that the model finished producing usable output. Install the Python SDK before running the example:

python -m pip install openai pydantic

With the SDK, check the response status and then retrieve its text:

from openai import OpenAI

client = OpenAI()  # reads OPENAI_API_KEY from the environment
response = client.responses.create(
    model="gpt-5.5",
    input="Reply with exactly: API connected.",
)

if response.status != "completed":
    raise RuntimeError(f"Response did not complete: {response.status}")
if not response.output_text:
    raise RuntimeError("The completed response did not contain text")

print(response.output_text)

OpenAI documents response.output_text as a convenience property for collecting text output. Responses can also finish as incomplete, so check the status rather than treating partial text as a completed result. (Text generation guide; Responses API reference) If the request fails, inspect the returned status and error body; also check the key, project access, model access, and billing setup.

Use structured output when your application needs a schema

For application data—such as a support-ticket category—use Structured Outputs with a schema rather than relying only on a prompt to produce valid JSON. OpenAI documents schema-constrained output for the Responses API, including SDK parsing with a Pydantic model and retrieval through response.output_parsed. (Structured Outputs guide)

Here is a small support-triage example:

from typing import Literal
from pydantic import BaseModel
from openai import OpenAI

class TicketTriage(BaseModel):
    category: Literal["billing", "bug", "account", "other"]
    priority: Literal["low", "medium", "high"]
    needs_human: bool

client = OpenAI()
response = client.responses.parse(
    model="gpt-5.5",
    input="A customer says they were billed twice and requests a refund.",
    text_format=TicketTriage,
)

if response.status != "completed":
    raise RuntimeError(f"Response did not complete: {response.status}")

triage = response.output_parsed
if triage is None:
    raise RuntimeError("No parsed triage result; do not route this ticket")

print(triage.model_dump())

Treat a refusal, incomplete response, or missing parsed result as unusable for the workflow. Then validate the result against your application’s own rules before routing or taking action. OpenAI’s guidance calls out checking for refusals and incomplete responses before parsing schema-constrained output. (Structured Outputs guide) A valid schema controls output shape; it does not prove a classification is correct or that a refund, escalation, or other external action has occurred.

Keep provider details distinct: api.openai.com, its model identifiers, and its request format are for OpenAI’s API. A third-party gateway may use different credentials, model names, endpoints, or payloads; do not assume its instructions apply unchanged.

GPT-5.5 API pricing

For budgeting, consult OpenAI’s current GPT-5.5 model and pricing pages and make sure the listed rate matches the processing option and token category you plan to use. This guide does not give a numeric cost estimate. (GPT-5.5 model documentation; API pricing)

OpenAI states that prompts with more than 272,000 input tokens are priced at 2× the input rate and 1.5× the output rate for the full session under standard, batch, and flex pricing. Check the current model and pricing pages before budgeting; rates and conditions can change. (GPT-5.5 model documentation)

Common integration checks

  • Confirm the provider: this example uses OpenAI’s api.openai.com endpoint, not a third-party gateway.
  • Confirm the model: use gpt-5.5 or the documented snapshot gpt-5.5-2026-04-23. (GPT-5.5 model documentation)
  • Protect the API key: keep it in a trusted server-side environment, not client-side code.
  • Check usable output: verify the request completed and returned text or parsed data before your application uses it.
  • Validate before acting: structured output does not replace application rules or human review for consequential actions.

Sources and scope

This guide covers the OpenAI API, not a third-party GPT-5 gateway. OpenAI’s model documentation lists GPT-5.5 identifiers, supported endpoints, Structured Outputs support, and pricing information. Check the current documentation when implementing because product details and prices may change.

Sources

GPT-5.5 Model | OpenAI API

OpenAI API Platform Documentation

Text generation | OpenAI API

Responses | OpenAI API Reference

Structured model outputs | OpenAI API

Pricing | OpenAI API

Managing projects in the API platform

Managing billing for ChatGPT and the API platform

OpenAI Python API library

Contact us