Embedding Problem with OpenAI

The Pinecone documentation uses
openai.Embedding.create(

which appears to be deprecated in the latest version of OpenAI. Keep getting error:

APIRemovedInV1:

You tried to access openai.Embedding, but this is no longer supported in openai>=1.0.0 - see the README at GitHub - openai/openai-python: The official Python library for the OpenAI API for the API.

Are there updated materials to walk through how to create embeddings for ada-02?

Hey @comedyshow, I can’t speak to the Pinecone guides or when they’ll be able to be updated, but in the meantime the changes look pretty straightforward.

You can find more info on OpenAI’s migration guide: v1.0.0 Migration Guide · openai/openai-python · Discussion #742 · GitHub

The main change is how to init the client:

# old
import openai

openai.api_key = os.environ['OPENAI_API_KEY']

# new
from openai import OpenAI

client = OpenAI(
  api_key=os.environ['OPENAI_API_KEY'],  # this is also the default, it can be omitted
)

and an API rename:
openai.Embedding.create()client.embeddings.create()

Hope this helps!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.