Skip to content

AttributeError: module 'openai' has no attribute 'api_base'. #784

@artwalker

Description

@artwalker

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Hello, I'm encountering an issue with my program EasyTranslator.

if len(self.api_proxy) == 0:
   print("-" * 3)
   print(f"\033[1;32mOpenAI API proxy not detected, currently using the api address: {openai.api_base}\033[0m") 
else:
   self.api_proxy_url = self.api_proxy + "/v1"
   openai.api_base = os.environ.get("OPENAI_API_BASE", self.api_proxy_url)
   print("-" * 3)
   print(f"\033[1;32mUsing OpenAI API proxy, the proxy address is: {openai.api_base}\033[0m")

The program consistently throws an error:
AttributeError: module 'openai' has no attribute 'api_base'. Did you mean: 'api_type'?

I also noticed that this attribute is indeed missing, as shown in the image below:
image

Could you please clarify if there's another attribute used in place of 'api_base,' or if it's deprecated?
Additionally, I'm using Azure to call the openai API's openai.api_base.
How should I address this problem? Thank you very much!

To Reproduce

  1. git clone https://github.com/artwalker/EasyTranslator.git
  2. cd EasyTranslator
  3. pip install -r preconditions.txt
  4. python easy_translator.py ./book/profile.txt

Code snippets

No response

OS

win 11

Python version

Python 3.12.0

Library version

openai v1.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions