Hi all,
How i can configure a valid OPENAI_API_KEY in my local environment to lunch launches Jupyter notbook.
when I tried to run M2_UGL_1 on my local machine I got an OpenAIError: Missing credentials.
OpenAIError Traceback (most recent call last)
Cell In[3], line 6
2 import re
3 import json
4
5 # Local helper module
----> 6 import utils
File d:\WorkSpace_coding\agentic_ai\M2\ungraded_labs\M2_UGL_1\utils.py:24
21 anthropic_api_key = os.getenv(“ANTHROPIC_API_KEY”)
23 # Both clients read keys from env by default; explicit is also fine:
—> [24](file:///D:/WorkSpace_coding/agentic_ai/M2/ungraded_labs/M2_UGL_1/utils.py:24) openai_client = OpenAI(api_key=openai_api_key) if openai_api_key else OpenAI()
25 anthropic_client = Anthropic(api_key=anthropic_api_key) if anthropic_api_key else Anthropic()
26 anthropic_client = Anthropic(
27 base_url=“http://jupyter-api-proxy.internal.dlai/rev-proxy/anthropic”
28 )
File d:\WorkSpace_coding\venv\Lib\site-packages\openai\_client.py:274, in OpenAI._init_(self, api_key, admin_api_key, workload_identity, organization, project, webhook_secret, provider, base_url, data_residency, websocket_base_url, timeout, max_retries, default_headers, default_query, http_client, _strict_response_validation, _enforce_credentials)
264 self.admin_api_key = admin_api_key if provider_runtime is None else None
266 if (
267 provider_runtime is None
268 and _enforce_credentials
(…) 272 and self.admin_api_key is None
273 ):
…
276 )
278 if organization is None and provider_runtime is None:
279 organization = os.environ.get("OPENAI_ORG_ID")
OpenAIError: Missing credentials. Please pass an `api_key`, `workload_identity`, `admin_api_key`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.