Chat Completions Basics
Chat Completions remains relevant when maintaining an existing messages-based integration. Evaluate Responses for a new workflow or a planned migration rather than rewriting a stable application merely to change terminology.
#Core model
The application supplies role-labelled messages and manages which conversation history is sent. A response can include text or tool-related content; inspect the returned structure rather than assuming every choice is a final answer.
pythonimport os from openai import OpenAI client = OpenAI(timeout=20.0) response = client.chat.completions.create( model=os.environ["OPENAI_MODEL"], messages=[ {"role": "system", "content": "Explain programming concepts clearly."}, {"role": "user", "content": "What is a generator?"}, ], ) print(response.choices[0].message.content)
This example assumes the configured model supports Chat Completions.
#Migration considerations
Inventory existing context storage, tools, images, retries and error handling. Responses offers a different item/response model; it is not a field-by-field rename of messages.
Start with one equivalent workflow, compare the results and preserve application-owned permissions and state. Add new tool/agent features deliberately rather than accumulating unsupported assumptions in a legacy wrapper.