How can i get API?

#6
by EEAB - opened

I am trying to run the Finegrain Object Eraser app, but I encounter an HTTPStatusError: 401 Unauthorized when making requests to the API. Below is a detailed explanation of the problem:

The error occurs at the point where the app makes a POST request to the API URL: https://spaces.finegrain.ai/eraser.
The error message is:
arduino
Копировать код
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://spaces.finegrain.ai/eraser'
The environment is set up using the environs library, and the API key is being loaded from a .env file:
python
Копировать код
env = Env()
env.read_env()

with env.prefixed("ERASER_"):
API_URL: str = str(env.str("API_URL", "https://spaces.finegrain.ai/eraser"))
API_KEY: str | None = env.str("API_KEY", None)
CA_BUNDLE: str | None = env.str("CA_BUNDLE", None)

auth = None if API_KEY is None else httpx.BasicAuth("hf", API_KEY)
I have verified that the API key is correctly set in the .env file, but the issue persists.
The key part of the request logic looks like this:
python
Копировать код
r = httpx.post(
API_URL,
data={"prompt": prompt},
files={"file": f},
verify=CA_BUNDLE or True,
timeout=30.0,
auth=auth,
)
r.raise_for_status()
What could be causing the 401 error, and how can I resolve the authentication issue?

This is an api-endpoint, you need to get their access token!

Sign up or log in to comment