HF_API_ITT_BASE is a KeyError at L2: Image captioning app notebook

KeyError Traceback (most recent call last)
Cell In[3], line 5
2 import requests, json
4 #Image-to-text endpoint
----> 5 def get_completion(inputs, parameters=None, ENDPOINT_URL=os.environ[‘HF_API_ITT_BASE’]):
6 headers = {
7 “Authorization”: f"Bearer {hf_api_key}",
8 “Content-Type”: “application/json”
9 }
10 data = { “inputs”: inputs }

File :678, in getitem(self, key)


Did you manage this error? I had the same problem. I assume that ‘HF_API_ITT_BASE’ is an environmental variable. I don’t know its value.
Any hint on this topic?
Best regards

HI All
I reply to myself.
The environment variable HF_API_ITT_BASE points to an Inference endpoint provided by HuggingFace. I created an inference endpoint on the HuggingFace website (Inference Endpoints - Hugging Face) and I was able to run locally the Jupyter Notebook. That’s it

Yup, instructions in this course is very vague… It should have been more clear and precise…

I got this api url by following below steps :

  1. Copy model name used : Which is Salesforce/blip-image-captioning-base.
  2. Go To : https://huggingface.co/models and search for above model : Salesforce/blip-image-captioning-base
  3. Open that model
  4. Click on Deploy. You will see an option Inference API
  5. Clicking on that will reveal API_URL which is free to use directly in your project.
1 Like

Thanks a lot @thakkar152 ! I noticed only one difference. In the ‘Deploy’ window I see ‘Inference API’, not ‘Interface API’, but it should be the same.

It was typo. Corrected now. Thanks

1 Like