匠人学院 JR Academy
Skip to article
Learning guide
OpenAI API Guide

Build with the OpenAI API using Responses API, streaming, tools, embeddings, and multimodal inputs.

3 chapters·9 guides·Access varies by chapter
Basics
On this page

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.

python
import 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.

Published by
JR Academy
Learning resources

Individual authors and reviewers are credited where recorded.

System Design

Core system design concepts and practical case studies

Learn the trade-offs and patterns that matter in technical interviews.

Open System Design →

Related Roadmaps

Done reading? Next steps