BaşlayınÜcretsiz Başlayın

Specifying an OpenAI model

OpenAI offers multiple models for different use cases. In this exercise, you'll specify the model and define the role to structure your API requests.

The OpenAI class has already been imported for you from the openai library.

Bu egzersiz

Working with the OpenAI API

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Specify the gpt-4o-mini model.
  • Assign the correct role in the messages list.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

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)
Kodu Düzenle ve Çalıştır