403 forbidden by replicate

INFO:httpx:HTTP Request: POST https://api.replicate.com/v1/files "HTTP/1.1 201 Created"
INFO:httpx:HTTP Request: POST https://api.replicate.com/v1/files "HTTP/1.1 201 Created"
INFO:httpx:HTTP Request: POST https://api.replicate.com/v1/predictions "HTTP/1.1 403 Forbidden"
ERROR:main:Replicate API error occurred: ReplicateError Details:
status: 403
ERROR:main:Full traceback of the error:
Traceback (most recent call last):
  File "/opt/render/project/src/fastapi/main.py", line 53, in query_replicate_and_upscale
    output = replicate.run(
             ^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/replicate/client.py", line 175, in run
    return run(self, ref, input, use_file_output=use_file_output, **params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/replicate/run.py", line 46, in run
    prediction = client.predictions.create(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/replicate/prediction.py", line 497, in create
    resp = self._client._request("POST", "/v1/predictions", json=body, **extras)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/replicate/client.py", line 89, in _request
    _raise_for_status(resp)
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/replicate/client.py", line 393, in _raise_for_status
    raise ReplicateError.from_response(resp)
replicate.exceptions.ReplicateError: ReplicateError Details:
status: 403

Hello, I am trying to access replicate’s api from the hosted fast api machine, having some issues as i get Forbidden 403 even after triple checking the api key input is correct. I am trying to download the file on a free instance, but it doesnt reach that step and fails at the request.

If you’ve verified the key is correct then the 403 is coming from Replicate so they would be the ones that you’d need to reach out to to understand the cause here. I couldn’t see anything in their docs around returned status codes that might give you further clues.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.