openai_response api

사우나도깨비·2025년 10월 23일

개발공부

목록 보기
5/10

상황별 어떤 모듈을(tool) 써야하는지 학습해보겠다.

DeprecationWarning!!

client.chat.completions(번역기 앱)
client.images.generate(이미지 앱)

이렇게 모델별로 쓰는 건(25.10) 가능은 하지만,warning이 뜬다.

DeprecationWarning: The Assistants API is deprecated in favor of the Responses API
  thread = client.beta.threads.create()

신버전 나왔으니 구버전 사용 지양하라는 에러이다...

Tools 로 변화


기존에는 기능별로 api를 불러오는법이 달랐다.
텍스트는 chat, 이미지는 images 처럼 각기 다르게 불러오니,
이를 통합적으로 활용하기 어려운 문제가 생긴것.

RESPONSE API로 통합


이젠 response api로 통합하여 아래 api로 모두 불러올 수 있다.

client.responses.create()
client.responses.stream()

이렇게 불러와진 api를 tools type으로 꺼내어 사용하면 된다.
tools 목록은 아래와 같다.

<예전 방식>

client.images.generate(
    model="gpt-image-1",
    prompt="A cat wearing sunglasses"
)

<현 방식>

client.responses.create(
    model="gpt-4.1",
    tools=[{"type": "image"}],
    input="Generate an image of a cat wearing sunglasses"
)

tools는 {"type": 타입명}으로 작성해주면 된다.

0개의 댓글