mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

bug: showing error when i use embed chain with open ai proxy base and key

Open vansh77swami opened this issue 2 years ago • 4 comments

🐛 Describe the bug

import os
from embedchain import App

os.environ["OPENAI_API_BASE"] = "https://chimeragpt.adventblocks.cc/api/v1"
os.environ["OPENAI_API_KEY"] = "my_key"
elon_musk_bot = App()

# Embed Online Resources
elon_musk_bot.add("https://en.wikipedia.org/wiki/Elon_Musk")
elon_musk_bot.add("https://www.tesla.com/elon-musk")

response = elon_musk_bot.query("How many companies does Elon Musk run?")
print(response)
# Answer: 'Elon Musk runs four companies: Tesla, SpaceX, Neuralink, and The Boring Company.'

error -

openai.error.AuthenticationError: Incorrect API key provided: E*******************************4. You can find your API key at https://platform.openai.com/account/api-keys.

vansh77swami avatar Aug 29 '23 05:08 vansh77swami

I think we just aren't processing the proxy path at all. This shouldn't be too hard of a fix.

cachho avatar Aug 29 '23 17:08 cachho

Same error, @cachho i need someting like openai.api_base = "https://chimeragpt.adventblocks.cc/api/v1"

karim23657 avatar Aug 31 '23 20:08 karim23657

agree it does not pickup the base url . Also n eed to ensure that it calls the AzureChatOpenAI function when passed the base url. The api_key in such instances is a b64 string that embeds the username and openai key. the parameters to be passed to AzureChatOpenAI are deployment_name, temperature, openai_api_base, openai_api_key, openai_aapi_version, openai_api_type .

ashyadav avatar Sep 06 '23 16:09 ashyadav

you can use langchain instead of proxy open_api_key and open_api_url ,eg:

openai_use_model = ChatOpenAI( model=OPENAI_MODEL, temperature=0.2, max_tokens=2000, openai_api_key=OPENAI_API_KEY, openai_api_base=OPENAI_BASE_URL )

config = { "llm": { "provider": "langchain", "config": { "model": openai_use_model } } }

spancer124 avatar Jun 12 '25 08:06 spancer124

Closing as fixed.

parshvadaftari avatar Sep 11 '25 19:09 parshvadaftari