I’m trying to import the embeddings utility functions from the OpenAI library but keep getting an import error. Here’s what I’m attempting to do:
from openai.text_utils import retrieve_embeddings
I have the OpenAI package installed in my environment:
Package: openai
Version: 0.26.5
Description: Python client library for the OpenAI API
Installed at: /Users/myname/Projects/ChatBot/env/lib/python3.9/site-packages
Dependencies: aiohttp, requests, tqdm
The package seems to be properly installed, but I still can’t access the embeddings utilities. Has anyone encountered this issue before? Am I missing something in my import statement or could this be a version compatibility problem?
OpenAI changed everything around version 1.0 - that text_utils module and retrieve_embeddings function don’t exist anymore. They were part of the old API. For embeddings now, just use the standard client: python import openai response = openai.embeddings.create( model="text-embedding-ada-002", input="your text here" ) You could downgrade to openai==0.28.1 if you really need those old utility functions, but I’d stick with the current API. It’s more stable and actually gets support.
Had this exact problem last month on a similar project. You’re using version 0.26.5 which has the old API structure. The text_utils module got deprecated and removed when OpenAI restructured their library. Two options: upgrade to the latest version (1.x) with new syntax, or downgrade to 0.28.1 if you need those old utility functions - it’s the last stable release before the major changes. I upgraded and the new API’s way cleaner once you get used to it. Migration took about an hour but totally worth it for better error handling and docs.
yep, it seems like they removed those utils in the latest updates. try using openai.embeddings.create() instead. downgrading is an option, but only do that if u really need the old stuff.