how-tos

GPT-6.2 API Guide: First Request in cURL & Python, Responses and Chat Completions

Poyo.ai Team
8 min read
Share:

GPT-6.2 API guide: first request in cURL and Python

This GPT-6.2 API guide takes you from an API key to a working request for gpt-6.2-sol or gpt-6.2-astra in cURL and the Python OpenAI SDK, on both the Responses and Chat Completions endpoints. Every request body follows PoYo's published schema and OpenAI's GPT-6.2 migration notes as of November 18, 2026. You can test prompts first on the GPT-6.2 Sol model page or the GPT-6.2 Astra model page.

New to the models? The GPT-6.2 API overview covers limits and positioning.

Before you start

Create a key in the PoYo dashboard and keep it on your server:

export POYO_API_KEY="your-poyo-key"
FormatEndpointUse it when
ResponsesPOST https://api.poyo.ai/v1/responsesNew code, function tools, image input, reasoning effort
Chat CompletionsPOST https://api.poyo.ai/v1/chat/completionsExisting Chat Completions code, text-only messages, no tools

Every request sends Authorization: Bearer $POYO_API_KEY. The examples use gpt-6.2-sol; replace it with gpt-6.2-astra for Astra. Request shapes are identical.

Three rules from OpenAI's GPT-6.2 guide apply to every example below:

  1. Do not send temperature or top_p. OpenAI says to omit them, plus logprobs and top_logprobs on Chat Completions and top_logprobs on Responses. PoYo's schemas still list temperature and top_p for older models.
  2. Do not set reasoning effort to none; the API rejects it.
  3. Put stable instructions in a developer message at the start of input. GPT-6.2 appends top-level instructions after input, which moves them out of the cacheable prefix.

First GPT-6.2 API request with cURL

curl https://api.poyo.ai/v1/responses \
  -H "Authorization: Bearer $POYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.2-sol",
    "input": [
      {"role": "developer", "content": "You are a code reviewer. Be specific and cite line numbers."},
      {"role": "user", "content": "Review this function for race conditions: ..."}
    ],
    "reasoning": {"effort": "medium"},
    "max_output_tokens": 8000,
    "store": false
  }'

model and input are required. input is a plain string or an array of items with role (developer, system, user, assistant) and content. Other documented fields used in this guide: reasoning, max_output_tokens, stream, store, tools, tool_choice, previous_response_id, and metadata.

The response is a Responses object returned directly. Text sits in output[].content[] blocks with type: "output_text"; the call status is in status; and counts are in usage.input_tokens, usage.output_tokens, and usage.total_tokens.

Python with the OpenAI SDK

Point the SDK at PoYo:

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.poyo.ai/v1", api_key=os.environ["POYO_API_KEY"])

resp = client.responses.create(
    model="gpt-6.2-sol",
    input=[
        {"role": "developer", "content": "You are a senior backend engineer."},
        {"role": "user", "content": "Write a migration plan from Celery 4 to Celery 5."},
    ],
    reasoning={"effort": "medium"},
    max_output_tokens=8000,
)

print(resp.output_text)
print(resp.status, resp.usage)

resp.output_text is the SDK's helper that joins every output_text block. Log resp.usage on every call; the cost section below reads it.

Chat Completions for existing code

If your code already uses chat.completions.create, change the model and remove sampling fields:

resp = client.chat.completions.create(
    model="gpt-6.2-sol",
    messages=[
        {"role": "system", "content": "You are a senior backend engineer."},
        {"role": "user", "content": "Explain the CAP theorem with one example per trade-off."},
    ],
    max_tokens=4000,
)
print(resp.choices[0].message.content, resp.choices[0].finish_reason)

The same request in cURL:

curl https://api.poyo.ai/v1/chat/completions \
  -H "Authorization: Bearer $POYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.2-sol",
    "messages": [{"role": "user", "content": "Explain vector databases in one sentence."}],
    "max_tokens": 1000
  }'

PoYo's Chat Completions schema documents model, messages (string content; roles system, user, assistant), max_tokens, stream, stop, n, and the penalty fields. It does not document tools, and OpenAI says GPT-6.2 tool calling requires Responses, so agents belong on /v1/responses.

Set reasoning effort through the GPT-6.2 API

OpenAI names the field reasoning.effort in Responses and reasoning_effort in Chat Completions. PoYo's Responses reference documents reasoning (example {"effort": "medium"}); its Chat Completions reference does not list reasoning_effort yet, so this guide sets effort on Responses only.

SituationSettingSource
New integrationmediumOpenAI: "Start with medium for a new integration."
Previously none or minimallowOpenAI GPT-6.2 migration note
Long or complex tasksA higher levelOpenAI: higher effort "can help it persist through the final checks"
noneRejectedOpenAI model pages

OpenAI's reasoning guide lists low, medium, high, xhigh, and max among possible values, but says they are model-dependent. The GPT-6.2 model pages do not list the accepted set, so send one test request before you hard-code a level above medium. Reasoning tokens are billed as output and count against max_output_tokens; OpenAI reports them in usage.output_tokens_details.reasoning_tokens.

Streaming GPT-6.2 API responses

With "stream": true, PoYo returns text/event-stream. Each data: line is JSON whose type names the event; text arrives as response.output_text.delta, and response.completed carries the final object with usage. PoYo sends no separate event: lines, and the stream ends with data: [DONE].

stream = client.responses.create(
    model="gpt-6.2-sol",
    input="Write a 100-word product introduction for a log search tool.",
    reasoning={"effort": "low"},
    max_output_tokens=2000,
    stream=True,
    store=False,
)

usage = None
for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    elif event.type == "response.completed":
        usage = event.response.usage
    elif event.type == "response.failed":
        raise RuntimeError(event.response)
print("\n", usage)

On Chat Completions, stream=True returns chat.completion.chunk events; text is in choices[0].delta.content and the last chunk carries usage.

Image input

GPT-6.2 accepts images with text. On PoYo, send them to Responses as input_image blocks with a public URL or a full Data URI (data:image/png;base64,...). PoYo's docs recommend text before images:

{
  "model": "gpt-6.2-sol",
  "input": [
    {
      "role": "user",
      "content": [
        {"type": "input_text", "text": "List every service in this architecture diagram that writes to the database."},
        {"type": "input_image", "image_url": "https://example.com/diagram.png"}
      ]
    }
  ],
  "max_output_tokens": 3000
}

Read usage and compute the cost of a request

PoYo prices per 1M tokens: Sol $1.60 input, $8 output, $0.08 cache read, $2 cache write; Astra $6.40, $32, $0.32, $8 (1 credit = $0.005).

OpenAI's caching guide reports billed cache reads in usage.input_tokens_details.cached_tokens and writes in usage.input_tokens_details.cache_write_tokens. PoYo's schema includes input_tokens_details and output_tokens_details without listing their keys, so read them defensively:

PRICES = {  # PoYo USD per 1M tokens: input, output, cache read, cache write
    "gpt-6.2-sol":   (1.60, 8.00, 0.08, 2.00),
    "gpt-6.2-astra": (6.40, 32.00, 0.32, 8.00),
}

def estimate_cost_usd(model: str, usage) -> float:
    p_in, p_out, p_read, p_write = PRICES[model]
    details = getattr(usage, "input_tokens_details", None)
    cached = getattr(details, "cached_tokens", 0) or 0
    written = getattr(details, "cache_write_tokens", 0) or 0
    fresh = usage.input_tokens - cached - written
    return (fresh * p_in + cached * p_read + written * p_write
            + usage.output_tokens * p_out) / 1_000_000

Treat this as an estimate and reconcile it with your PoYo usage log. Every price here is a short-context rate. OpenAI charges more above 272K input tokens, so check the model page for any request that large. Worked examples are in GPT-6.2 API pricing.

Errors worth handling

HTTPCauseWhat to do
400Invalid field (validation_error, details listed)Fix the body; a none effort or an undocumented field can land here
401Missing or invalid API keyCheck the Authorization header
402Insufficient creditsTop up before retrying
404Unknown model (model_not_found)Check the ID: gpt-6.2-sol, gpt-6.2-astra
429Rate limitedWait and retry
500 / 502 / 503Server or upstream errorRetry with exponential backoff

PoYo's docs say LLM endpoints are currently not rate limited, but handle 429 anyway. With the OpenAI SDK, catch openai.APIStatusError and branch on status_code. Retry only 5xx and 429; a 400 fails again until the body changes. Full bodies are in PoYo error codes.

Checklist before you ship

  • Keep POYO_API_KEY server-side; never ship it in browser or mobile code.
  • Remove temperature and top_p from every GPT-6.2 request path, including shared helper functions.
  • Always set max_output_tokens (or max_tokens), and leave room for reasoning tokens inside that cap.
  • Log status / finish_reason and the full usage block next to your own request ID, so truncated answers and cost spikes are visible.
  • Put long, stable context in the first developer message and the changing question last, which gives prompt caching a chance to apply.
  • Pin the model ID in config, so you can switch between gpt-6.2-sol and gpt-6.2-astra without a deploy.

For tools, streaming tool calls, and caching in long agent sessions, continue with GPT-6.2 API for coding agents.

Frequently asked questions

How do I call the GPT-6.2 API in Python?

Use the OpenAI SDK with base_url="https://api.poyo.ai/v1", your PoYo key, and model="gpt-6.2-sol" or "gpt-6.2-astra" in client.responses.create.

Does the GPT-6.2 API support streaming?

Yes, on both endpoints. Set stream: true; Responses sends typed events such as response.output_text.delta and Chat Completions sends chat.completion.chunk events. Both end with data: [DONE].

How do I set GPT-6.2 API reasoning effort?

Send "reasoning": {"effort": "medium"} on /v1/responses. OpenAI recommends medium to start and rejects none.

Why does my GPT-6.2 API request fail with temperature?

OpenAI says to omit temperature and top_p for GPT-6.2. Remove them and control output length with max_output_tokens or max_tokens.

How do I send an image to the GPT-6.2 API?

Use /v1/responses with an input_image block (URL or Data URI) after an input_text block. PoYo's Chat Completions schema documents string content only.

Share: