Skip to content

Rate limit problem #10

@localjo

Description

@localjo

I'm trying to follow the example here, and getting an error. To get the example to work, I had to add my API key, so I just did openai.api_key = "sk-mykey, but now I am getting the following error:

RateLimitError                            Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/tenacity/__init__.py:407, in Retrying.__call__(self, fn, *args, **kwargs)
    406 try:
--> 407     result = fn(*args, **kwargs)
    408 except BaseException:  # noqa: B902

File ~/opt/anaconda3/lib/python3.9/site-packages/openai/embeddings_utils.py:23, in get_embedding(text, engine)
     21 text = text.replace("\n", " ")
---> 23 return openai.Embedding.create(input=[text], engine=engine)["data"][0]["embedding"]

File ~/opt/anaconda3/lib/python3.9/site-packages/openai/api_resources/embedding.py:34, in Embedding.create(cls, *args, **kwargs)
     33 try:
---> 34     response = super().create(*args, **kwargs)
     36     # If a user specifies base64, we'll just return the encoded string.
     37     # This is only for the default case.

File ~/opt/anaconda3/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py:115, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
    114 url = cls.class_url(engine, api_type, api_version)
--> 115 response, _, api_key = requestor.request(
    116     "post",
    117     url,
    118     params=params,
    119     headers=headers,
    120     stream=stream,
...
--> 361     raise retry_exc from fut.exception()
    363 if self.wait:
    364     sleep = self.wait(retry_state=retry_state)

RetryError: RetryError[<Future at 0x179356970 state=finished raised RateLimitError>]

I have credit in my account, and only ~300 short sentences in my CSV. I'm surprised to be running into a rate limit, but is there a recommended way to throttle requests for this example? I should add that I'm not a Python developer, I'm just trying to figure out how to replace the search API with the embeddings API, and since the only documentation for that replacement is a Python example, I'm just trying to get the example to run so I know what I need to do in my own app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions