OpenAI Responses API vs Chat Completions: what changes in your code
Side-by-side Python for the Responses API and Chat Completions: inputs, output_text, state with previous_response_id, tools, structured output and streaming.
OpenAI SDK: The OpenAI Agents SDK
In part 07 you wrote the tool loop by hand. The Agents SDK ( pip install openai-agents ) packages that loop with a few primitives: an Agent (instructions + tools…
OpenAI SDK: Async client & concurrency
Each API call spends almost all its time waiting for the model. Classifying 1,000 support tickets one at a time at 1.5 s each takes 25 minutes, and your CPU is idle…
OpenAI SDK: Built-in tools
Function tools (part 07) run in your code. Built-in (hosted) tools run on OpenAI's side within the same request: web search , file search over your uploaded…
OpenAI SDK: Conversation state & memory
The model is stateless (part 01), so a chat must supply earlier turns on every call.
OpenAI SDK: Cost & latency optimisation
LLM costs scale with tokens × price × requests, and latency scales mostly with output length and model size.
OpenAI SDK: Embeddings & semantic search
An embedding is a list of numbers (a vector) that represents the meaning of a piece of text.
OpenAI SDK: Errors, retries & timeouts
Network calls fail. Rate limits are hit, servers have bad minutes, requests are malformed, keys expire.
OpenAI SDK: Files, vector stores & managed retrieval
To answer questions from your own documents (policies, manuals, contracts), the model needs the relevant passages in its input.
OpenAI SDK: Function calling: the tool loop
A model cannot query your database or call your API. What it can do is ask you to . You describe functions (name, purpose, JSON Schema for the arguments).
OpenAI SDK: How the OpenAI API works
Under every chatbot, agent and 'AI feature' is the same exchange: your code sends an HTTP request containing a model name and some input, and gets back output plus…
OpenAI SDK: Models, parameters & tokens
Which model you call decides quality, speed and cost more than any prompt trick.
OpenAI SDK: Images, files & audio
Current models read images and PDFs as naturally as text: a receipt photo, a chart screenshot, a 40-page contract.
OpenAI SDK: Project: retail analyst assistant
Ask 'which category earned the most from completed orders?' in plain English and get a correct answer, with the numbers, the SQL that produced them, and caveats…
OpenAI SDK: Realtime & voice
A voice assistant built from three calls (transcribe → think → speak, part 09) works, but each hop adds latency, and conversation feels stilted.
OpenAI SDK: Responses API vs Chat Completions
OpenAI has two APIs for generating text. Chat Completions ( client.chat.completions.create ) is the older, widely copied format: a list of messages in, one message…
OpenAI SDK: Safety, moderation & data handling
An LLM feature has a new kind of attack surface: text . Users can type instructions, documents and web pages can contain hidden instructions, and the model's output…
OpenAI SDK: Setup, keys & your first call
Setup takes five minutes: a virtual environment, the openai package, and an API key in an environment variable .
OpenAI SDK: Streaming responses
A model generates output one token at a time. Without streaming you wait for the whole answer, perhaps 8 seconds for a long reply, and see nothing meanwhile.
OpenAI SDK: Structured outputs with Pydantic
Most application code does not want prose. It wants data : a category, an extracted invoice, a list of action items.
OpenAI SDK: Testing & evaluating LLM code
LLM features need two different kinds of checking. Tests check your code : does the tool loop pass the right call_id back, handle a 429, parse the schema, refuse an…