Hello everyone,
I am new to Crewai and trying to use an OpenAI model through the SAP proxy client. My code looks like this:
from gen_ai_hub.proxy.langchain.openai import ChatOpenAI
from gen_ai_hub.proxy.core.proxy_clients import get_proxy_client
def init(self):
proxy_client = get_proxy_client(‘gen-ai-hub’)
self.llm_model = ChatOpenAI(proxy_model_name=‘gpt-4o’, proxy_client=proxy_client, temperature=0)
@agent
def researcher(self) → Agent:
return Agent(
config=self.agents_config[‘researcher’],
verbose=True,
llm = self.llm_model
)
To get this working, I have set the following environment variables:
AICORE_CLIENT_ID
AICORE_CLIENT_SECRET
AICORE_BASE_URL
However, when I run the code, I get an error stating that the OpenAI API key is missing. I do not have any API key since I do not have access to the OpenAI API directly.
Error: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
Is there a way to avoid this error while using the proxy client, or am I possibly missing a configuration step? Any guidance would be greatly appreciated!
Thanks in advance!