# GPT family API: model IDs, Chat Completions vs. Responses, web search and errors Source: https://ofox.io/docs/develop/models/gpt OpenAI's GPT text models, including the GPT-6, GPT-5.x, GPT-4.1, GPT-4o and Codex series. They are called through the OpenAI-compatible API, which supports both **Chat Completions** and **Responses**; the official OpenAI SDK works once you change `base_url`. ## Common tasks - [Enable reasoning](https://ofox.io/docs/develop/models/gpt/reasoning) — reasoning_effort values, reasoning tokens, reasoning summaries. - [Web search](#web-search) — The web_search tool on the Responses API. - [Prompt caching](#caching) — Automatic caching and confirming hits. - [Structured output & PDF](https://ofox.io/docs/develop/models/gpt/structured-output) — json_schema output and PDF file input. - [Troubleshooting errors](#errors) — Context exceeded, max_tokens too large, empty responses, unsupported endpoint. - [Use in Codex](https://ofox.io/docs/integrations/codex) — Setup and common questions. ## Models All models support tool calling and structured output; all except GPT-5 nano accept image input. For the full model list and live prices, see the [model page](https://ofox.io/models?provider=openai), or query the [Models API](https://ofox.io/docs/api/openai/models). **Common model IDs (copy them exactly)** - GPT-6 Sol: `openai/gpt-6-sol` - GPT-5.4: `openai/gpt-5.4` - GPT-5.4 mini: `openai/gpt-5.4-mini` - GPT-4.1 mini: `openai/gpt-4.1-mini` — No reasoning; suited to simple tasks You can omit the `openai/` prefix, e.g. `gpt-5.4`. The `model` field in responses always includes the prefix. ## Choosing an endpoint **Key point**:The Codex series and GPT-5.4 Pro support only the Responses API; all other models work with both. | | Chat Completions | Responses | |---|---|---| | Endpoint | `POST https://api.ofox.io/v1/chat/completions` | `POST https://api.ofox.io/v1/responses` | | Input | `messages` | `input` (a string or an array of messages) | | Output limit | `max_completion_tokens` (`max_tokens` also accepted) | `max_output_tokens` | | [Reasoning effort](https://ofox.io/docs/develop/models/gpt/reasoning) | `reasoning_effort` | `reasoning.effort` | | Reasoning summary | Not returned | `reasoning.summary` — see [Reasoning summaries](https://ofox.io/docs/develop/models/gpt/reasoning#reasoning-summary) | | Web search | Not supported | `web_search` tool | | Models available only here | — | `openai/gpt-5.4-pro`, `openai/gpt-5.3-codex`, `openai/gpt-5.2-codex` | For the full request parameters, see the [Chat Completions API](https://ofox.io/docs/api/openai/chat-completions) and the [Responses API](https://ofox.io/docs/api/openai/responses). ### Providers | Provider | Models | |---|---| | Azure AI Foundry (`azure_foundry`) | All models; default provider | | OpenAI (`openai`) | GPT-6 Sol, GPT-6 Luna, GPT-6 Astra, GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna | In our tests, both providers behaved the same for reasoning, caching and web search. To select a provider, add the `X-OfoxAI-Provider-Type: openai` request header; for other methods, see [Provider routing](https://ofox.io/docs/develop/advanced/provider-routing). ## Examples **Python (Chat Completions)** ```python filename="gpt_chat.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="openai/gpt-5.4", messages=[ {"role": "system", "content": "You are a senior backend engineer. Keep answers concise."}, {"role": "user", "content": "Explain idempotency in one sentence."}, ], ) print(resp.choices[0].message.content) ``` **Python (Responses)** ```python filename="gpt_responses.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.responses.create( model="openai/gpt-5.4", instructions="You are a senior backend engineer. Keep answers concise.", input="Explain idempotency in one sentence.", ) print(resp.output_text) ``` **cURL** ```bash filename="Terminal" curl https://api.ofox.io/v1/chat/completions \ -H "Authorization: Bearer $OFOX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-5.4", "messages": [{"role": "user", "content": "Explain idempotency in one sentence."}] }' ``` ## Prompt caching **Key point**:The GPT family caches automatically with no changes to your request. Put fixed content at the start of the request to improve the hit rate. When a request's prefix matches a recent request and is long enough, it hits the cache automatically, and the cached portion is billed at the cache read rate. | Item | Details | |---|---| | Confirming hits | In Chat Completions, `usage.prompt_tokens_details.cached_tokens` is greater than 0; in Responses, `usage.input_tokens_details.cached_tokens` | | Writes | The GPT-6 and GPT-5.6 series return `prompt_tokens_details.cache_write_tokens` on the first request, billed at the cache write rate | | Minimum length | Prefixes that are too short are not cached; for the minimum length, see the [OpenAI docs](https://platform.openai.com/docs/guides/prompt-caching) | | Reliability | Caching is best-effort; requests with the same prefix may still miss | For general information on caching, see [Prompt caching](https://ofox.io/docs/develop/advanced/prompt-caching). ## Web search Add `web_search` to `tools` on the Responses API, and the model runs searches on its own and cites sources. Chat Completions does not support web search. ```python filename="gpt_web_search.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.responses.create( model="openai/gpt-5.4", tools=[{"type": "web_search"}], input="What is the latest stable version of Python?", ) print(resp.output_text) print("Searches:", sum(1 for item in resp.output if item.type == "web_search_call")) ``` Each `web_search_call` item in `output` is one search, and the `message` item is the final answer. Searches are billed per use; see the [model page](https://ofox.io/models/openai/gpt-5.4) for the rate. ## Common errors **Key point**:Parameter errors return 400 with a reason. Long reasoning occasionally causes 502 or 504; use streaming and set a long timeout. | HTTP · type | Error message | Cause | Fix | |---|---|---|---| | 400 `invalid_request_error` | `This model's maximum context length is 128000 tokens. However, your messages resulted in 152008 tokens.` | Input exceeds the model's context window | Shorten the input, or switch to a model with a longer context | | 400 `invalid_request_error` | `max_tokens is too large: 100000. This model supports at most 16384 completion tokens` | Output limit exceeds the model's maximum | Lower `max_completion_tokens` | | 400 `invalid_request_error` | `Invalid value: 'bogus'. Supported values are: 'low', 'medium', 'high', and 'xhigh'.` | The `reasoning_effort` value is not supported by this model | Use one of the values listed in the error message | | 400 `endpoint_not_supported` | `Model 'openai/gpt-5.4-pro' does not support the /v1/chat/completions endpoint on this platform.` | The model supports only the Responses API | Use `/v1/responses` | | 404 `model_not_found` | `Model 'openai/gpt-9' not found` | Model ID misspelled, or the model has been retired | Copy the model ID from this page | | 429 `rate_limit_error` | `Rate limit reached for the requested model. Please retry after a short delay.` | Too many requests | Retry later — see [Rate limits](https://ofox.io/docs/develop/guides/rate-limits) | | 502 `upstream_error` | `The model service is temporarily unavailable. Please retry or switch to another model.` | Upstream service temporarily unavailable | Retry later, or switch to another model | | 504 `gateway_timeout` | `The upstream service did not respond in time.` | Reasoning took too long and upstream did not respond in time | Use streaming, or lower the reasoning effort | | 200, `finish_reason: "length"` with an empty answer | — | Reasoning used up `max_completion_tokens` | Increase `max_completion_tokens`, or lower the reasoning effort | For other general errors, see [Error Handling](https://ofox.io/docs/develop/guides/error-handling). ## Official docs - [OpenAI · Models overview](https://platform.openai.com/docs/models) - [OpenAI · Reasoning models](https://platform.openai.com/docs/guides/reasoning) - [OpenAI · Responses vs. Chat Completions](https://platform.openai.com/docs/guides/responses-vs-chat-completions) - [OpenAI · Prompt caching](https://platform.openai.com/docs/guides/prompt-caching) - [OpenAI · Web search](https://platform.openai.com/docs/guides/tools-web-search) The official docs describe behavior when calling OpenAI directly. When calling through OfoxAI, model IDs and endpoints on this page take precedence. ## FAQ **How do I write a GPT model ID?** The standard format is openai/gpt-5.4. You can also omit the openai/ prefix and write gpt-5.4. **Should I use Chat Completions or Responses?** Either works. The Codex series and GPT-5.4 Pro support only Responses, and you also need Responses for reasoning summaries or web search. Projects with existing Chat Completions code can keep using it. **How do I enable reasoning for GPT?** In Chat Completions, pass reasoning_effort (e.g. "high"); in Responses, pass reasoning: {"effort": "high"}. Some models do not reason by default, so pass it explicitly when you need it. **Why is the GPT response empty with finish_reason length?** Reasoning tokens count toward max_completion_tokens, and once reasoning uses up the budget no answer is produced. Increase max_completion_tokens or lower reasoning_effort. **What does the error does not support the /v1/chat/completions endpoint mean?** The model supports only the Responses API, e.g. gpt-5.4-pro, gpt-5.3-codex and gpt-5.2-codex. Use POST /v1/responses instead. **Can I see the GPT reasoning process?** Use the Responses API and pass reasoning: {"effort": "medium", "summary": "auto"}; the reasoning items in output will contain a reasoning summary. Chat Completions does not return reasoning content. **Can GPT search the web?** Yes. Use the Responses API and add {"type": "web_search"} to tools. Chat Completions does not support web search. **Do I need to enable GPT prompt caching manually?** No. When the prefix is long enough and matches a recent request, it hits the cache automatically; the cached amount is in cached_tokens in usage. **What should I do if GPT requests time out or return 504?** High-effort reasoning can take a long time. Use streaming (stream: true), set the client timeout to 600 seconds or more, or lower reasoning_effort.