Hello All,
I am using sentence-transformers/paraphrase-MiniLM-L6-v2 while using the API. but getting the 404 error. We are in free plan. any help please
Hello All,
I am using sentence-transformers/paraphrase-MiniLM-L6-v2 while using the API. but getting the 404 error. We are in free plan. any help please
Hello All, Its seems no model is accessiable via API access..iPlease confirm if any one is also facing the same issue.
import requests
API_TOKEN = “hf”
API_URL = “https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-MiniLM-L6-v2”
headers = {“Authorization”: f"Bearer {API_TOKEN}"}
def test_huggingface_api():
data = {
“inputs”: “This is a test sentence.”
}
response = requests.post(API_URL, headers=headers, json=data)
print("Status Code:", response.status_code)
if response.ok:
print("API is working âś…")
print("Response:", response.json())
else:
print("API error ❌")
print("Error Message:", response.text)
test_huggingface_api()
OutPut ::::Status Code: 404
API error
Error Message: Not Found
I have the same problem, the Inference API still returns a 404 error when calling curl in bash, client in Python or visit the url in interface web.
Please make sure to hide or remove your API token, it’s not secure to post it publicly.
It looks like you’re receiving a 404 error when trying to access sentence-transformers/paraphrase-MiniLM-L6-v2
via the Hugging Face API. This usually happens if the model is unavailable or there’s API endpoint. Here’s how you can fix it:
Check Model Availability: Visit the model’s page to ensure it’s still hosted. If it’s been removed, you may need to find an alternative.
Verify API Endpoint: Make sure you’re using the correct API request. The right format should be:
headers = {"Authorization": f"Bearer {your_token}"}
API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-MiniLM-L6-v2"
response = requests.post(API_URL, headers=headers, json={"inputs": "Your text here"})
print(response.json())
If the model has moved, the API URL may need to be updated.
Free Plan Limitations: Some models require authentication or a paid plan. If you’re using the free tier, make sure the model is accessible to free users. You may need to run it locally instead.
If these steps don’t resolve the issue, let me know what error message you’re getting, and I’ll be happy to assist further!
Best,
Don’t forget to disable the token that has been leaked.
Currently, almost all models for users are returning 404 errors. @michellehbn
Thanks , this has been removed and deleted as well
I couldn’t find much on the matter.
import requests
API_URL = “https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-MiniLM-L6-v2”
your_token = “your_actual_api_token”
input_text = “Your actual text here”
headers = {“Authorization”: f"Bearer {your_token}"}
response = requests.post(API_URL, headers=headers, json={“inputs”: input_text})
if response.status_code == 404:
print(“Model not found or API URL is incorrect”)
elif response.status_code == 401:
print(“Invalid API token”)
elif response.status_code == 429:
print(“Rate limit exceeded”)
else:
print(“Error:”, response.text)
This code snippet appears to be testing the Hugging Face API using the requests
library in Python. Let’s break it down:
The code seems mostly correct, but here are a few potential issues:
your_token
should be replaced with an actual API token.Here’s a slightly modified version with some improvements:
import requests
import json
API_URL = "https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-MiniLM-L6-v2"
your_token = "your_actual_api_token" # Replace with your API token
input_text = "Your actual text here" # Replace with your input text
headers = {"Authorization": f"Bearer {your_token}"}
response = requests.post(API_URL, headers=headers, json={"inputs": input_text})
if response.ok:
print("API is working ")
print("Response:", response.json())
else:
print("API error ")
print("Status Code:", response.status_code)
print("Error Message:", response.text)
Make sure to replace your_actual_api_token
and Your actual text here
with your actual API token and input text, respectively.