Error while executing code

Hello,
I am using google collab, when I use open ai key

import os

from google.colab import userdata

Get the API keys using the userdata module

openai_api_key = userdata.get(‘openai’)

Set the environment variable

os.environ[“OPENAI_API_KEY”] = openai_api_key

os.environ[“OPENAI_MODEL_NAME”] = ‘gpt-3.5-turbo’

I am getting the following error

RateLimitError Traceback (most recent call last)
in <cell line: 1>()
----> 1 result = crew.kickoff(inputs=inputs)

22 frames
/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
1018
1019 log.debug(“Re-raising status error”)
→ 1020 raise self._make_status_error_from_response(err.response) from None
1021
1022 return self._process_response(

RateLimitError: Error code: 429 - {‘error’: {‘message’: ‘You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.’, ‘type’: ‘insufficient_quota’, ‘param’: None, ‘code’: ‘insufficient_quota’}}

However, when I use HF

from google.colab import userdata
from langchain_community.llms import HuggingFaceEndpoint

Get the API key using the userdata module

HF_token = userdata.get(‘HF’)

Use the new class here

llm = HuggingFaceEndpoint(
repo_id=“HuggingFaceH4/zephyr-7b-beta”,
huggingfacehub_api_token=HF_token,
task=“text-generation”,
)

I am getting following error,

AuthenticationError Traceback (most recent call last)
in <cell line: 1>()
----> 1 result = crew.kickoff(inputs={
2 “customer”: “DeepLearningAI”,
3 “person”: “Andrew Ng”,
4 “inquiry”: "I need help with setting up a Crew "
5 "and kicking it off, specifically "

18 frames
/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
1018
1019 log.debug(“Re-raising status error”)
→ 1020 raise self._make_status_error_from_response(err.response) from None
1021
1022 return self._process_response(

AuthenticationError: Error code: 401 - {‘error’: {‘message’: ‘Incorrect API key provided: fake. You can find your API key at https://platform.openai.com/account/api-keys.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_api_key’}}

Can Someone help me with this?

Thanks,
Ratheesh

1 Like

To resolve the above error, kindly refer the below link which explains the step for you to follow