OpenAI Responses API ile Çalışmak
James Chapman
AI Curriculum Manager, DataCamp


| Olay Türü | Açıklama |
|---|---|
response.created |
Model üretmeye başladı |
response.output_text.delta |
Kısmi metin güncellemesi |
response.output_text.done |
Metin bloğu tamamlandı |
response.function_call.arguments.delta |
Araç argümanları akışta |
response.completed |
Tüm yanıt tamamlandı |
prompt = "Explain the seasons of the year concisely to a child."with client.responses.create(model="gpt-5-mini", input=prompt, stream=True) as stream:current_text = ""for event in stream: if event.type == "response.output_text.delta":current_text += event.delta print(current_text)

prompt = "Explain how a neural network learns concisely for a child." with client.responses.create(model="gpt-5-mini", input=prompt, stream=True) as stream:for event in stream: if event.type == "response.created":Print("Yanıt başladı...\n")elif event.type == "response.output_text.done":Print("\n\n--- Metin bloğu bitti ---\n")elif event.type == "response.completed":Print(f"\nTam yanıt:\n{current_text}")

convert_currency() -> str:
date_time: strfrom_timezone: strto_timezone: strtools = [
{
"type": "function",
"name": "convert_currency",
...
}
]

prompt = "How much is 120 euros in British pounds using the current exchange rate?"with client.responses.create(model="gpt-5-mini", input=prompt, tools=tools, stream=True) as stream:current_args = ""for event in stream: if event.type == "response.function_call_arguments.delta":current_args += event.delta print("Argümanlar akışta:", current_args)elif event.type == "response.function_call_arguments.done":print("\nNihai argümanlar:", event.arguments)elif event.type == "response.completed":print("\n--- Tamamlandı ---")


OpenAI Responses API ile Çalışmak