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

Creating embeddings

In this exercise, you'll create your very first embeddings using the OpenAI API. Normally, to interact with the OpenAI API, you would need an OpenAI API key, and creating embeddings would incur a cost. However, you do not need to create or provide an API key in this course.

The <OPENAI_API_TOKEN> placeholder has been provided in the code, which will send valid requests for the exercises in this course. If, at any point in the course, you hit a RateLimitError, pause for a moment and try again.

The OpenAI class from the openai library will be imported for you throughout the course, and after this exercise, the client will be created for you.

Bu egzersiz

Introduction to Embeddings with the OpenAI API

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

Egzersiz talimatları

  • Create an OpenAI client (you can leave the api_key set to the placeholder provided).
  • Create a request to the Embeddings endpoint, passing the text-embedding-3-small model any text you wish.
  • Convert the model response into a dictionary.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create an OpenAI client
client = ____(api_key="")

# Create a request to obtain embeddings
response = ____

# Convert the response into a dictionary
response_dict = ____
print(response_dict)
Kodu Düzenle ve Çalıştır