OpenAI 모델 지정하기
OpenAI는 다양한 사용 사례에 맞는 여러 모델을 제공합니다. 이번 연습에서는 모델을 지정하고 역할을 정의하여 API 요청을 구성해 보겠습니다.
openai 라이브러리에서 OpenAI 클래스는 이미 임포트되어 있습니다.
이 연습은 강의의 일부입니다
OpenAI API 활용하기
연습 안내
gpt-4o-mini모델을 지정하세요.messages리스트에 올바른 역할을 지정하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
client = OpenAI(api_key="")
response = client.chat.completions.create(
# Specify the model
model="____",
messages=[
# Assign the correct role
{"role": "____",
"content": "Announce my new AI Engineer role on LinkedIn."}]
)
print(response.choices[0].message.content)