Congratulations!

Working with the OpenAI Responses API

James Chapman

AI Curriculum Manager, DataCamp

Chapter 1: Welcome to the Responses API

 

response = client.responses.create(
    model="gpt-5-mini",
    input="What is recursion?",
    reasoning={"effort": "minimal"},
    max_output_tokens=500
)

responses_api_logo.jpg

Working with the OpenAI Responses API

Chapter 2: Web Search

web_search.png

Working with the OpenAI Responses API

Chapter 2: Function-Calling Tools

fct6.jpg

Working with the OpenAI Responses API

Chapter 3: Structured Outputs

from pydantic import BaseModel

class QuizResult(BaseModel):
    score: int
    passed: bool
    feedback: str
result = response.output_parsed

print(f"Score: {result.score}/10")
print(f"Passed: {result.passed}")
print(f"Feedback: {result.feedback}")
response = client.responses.parse(
    model="gpt-5-mini",
    instructions="...",
    input="...",
    text_format=QuizResult
)
Working with the OpenAI Responses API

Chapter 3: Streaming and Semantic Events

  • stream=True

 

Event Type Description
response.created The model has started generating
response.output_text.delta Partial text update
response.output_text.done Text block complete
response.function_call.arguments.delta Streaming tool arguments
response.completed The entire response is finished
Working with the OpenAI Responses API

Chapter 3: Multimodality

- Summary: A mild down day - closed at
277.18, down about 0.26% from the previous
close; after-hours ticked slightly lower to
276.94.

aapl_yahoo_finance.jpg

1 Apple, Inc. Stock Plot from yahoo!finance
Working with the OpenAI Responses API

Let's practice!

Working with the OpenAI Responses API

Preparing Video For Download...