Responses API
POST /v1/responses реализует OpenAI Responses API — более новый интерфейс,
который используется в OpenAI Agents SDK и инструментах в стиле Codex.
resp = client.responses.create( model="gpt-5.6-luna", instructions="You are a helpful assistant.", input="Explain recursion in one sentence.",)print(resp.output_text)Стриминг
Заголовок раздела «Стриминг»with client.responses.stream( model="gpt-5.6-luna", input="Write a limerick about a cat.",) as stream: for event in stream: if event.type == "response.output_text.delta": print(event.delta, end="", flush=True)События включают response.created, response.output_text.delta и
response.completed.
Уровень рассуждений
Заголовок раздела «Уровень рассуждений»resp = client.responses.create( model="gpt-5.6-luna", input="Plan a 3-day trip to Rome.", reasoning={"effort": "low"},)Структурированный вывод
Заголовок раздела «Структурированный вывод»resp = client.responses.create( model="gpt-5.6-luna", input="Name the capital of Japan.", text={"format": { "type": "json_schema", "name": "city", "strict": True, "schema": { "type": "object", "properties": {"city": {"type": "string"}, "country": {"type": "string"}}, "required": ["city", "country"], "additionalProperties": False, }, }},)print(resp.output_text)Responses API доступен для моделей GPT. Для моделей Claude и Gemini используйте Chat Completions или их нативные форматы.