Install
Requires Python 3.10+.Chat Completions
Save aschat.py.
Responses
Save asresponses.py. Select a Responses-compatible model first.
Run and handle results
completed status. output_text is an SDK convenience property that joins text; handle tools and other non-text output separately.
Streaming · Error handling
Reference: Official OpenAI Python SDK documentation。
The text-only Responses example rejects empty text, refusals, tool calls, and incomplete output. Continue with the full Responses examples in conversations, tool calling, and structured output.
简体中文