본문 바로가기
C.W.K.
Stream
Lesson 04 of 08 · published

Responses API — 새 front door

~22 min · responses-api, stateful, input

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

responses.create() 는 OpenAI 가 새 코드에 권장하는 API 야. Chat Completions 도 계속 동작하지만, built-in tools, semantic streaming, background mode, reasoning controls 같은 새 기능은 Responses 에 먼저 추가돼. 새로 시작한다면 Responses 를 기준으로 잡는 게 좋아.

바로 체감하는 차이 세 가지

  1. previous_response_id 로 대화를 이어 — turn 마다 전체 message 배열을 다시 보낼 필요가 없어. 직전 응답의 ID 와 새 입력만 보내면 서버가 앞선 대화를 연결해줘. 요청이 단순해지고 되풀이해서 보내는 token 도 줄어.
  2. response.output_text — assistant 가 만든 최종 텍스트를 바로 꺼낼 수 있어. completion.choices[0].message.content 를 따라 들어가지 않아도 돼.
  3. instructions= — system 성격의 지시는 message 안이 아니라 최상위 instructions parameter 에 넣어.

기존 Chat Completions 코드는 어떻게 할까?

잘 돌아가는 코드를 한꺼번에 뒤집을 필요는 없어. 호출부를 수정하거나 새 기능을 붙일 때 그 파일의 chat.completions.createresponses.create 로 함께 옮겨. 이렇게 조금씩 바꾸면 큰 마이그레이션 사고 없이 자연스럽게 끝낼 수 있어.

Code

최소한의 responses.create() 호출·python
from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-5.4",
    input="Explain quantum entanglement in simple terms."
)
print(response.output_text)  # convenience property

External links

Exercise

전체 메시지 배열을 다시 보내지 말고 previous_response_id 만 이용해 네 turn 짜리 대화를 진행해. turn 마다 response.id 와 response.previous_response_id 를 출력해서 응답들이 어떻게 이어지는지 직접 확인해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.