-
Notifications
You must be signed in to change notification settings - Fork 347
Open
Description
Calling inference api to call model for text generation.
But now getting 404 not found
, this setup was working earlier. What's missing here? any new change rolled out that I'm not aware of?
Code:
HF_API_URL = f"https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3"
HEADERS = {
"Authorization": f"Bearer {settings.HF_TOKEN}"
}
async def query_hf_api(payload: dict) -> str:
async with aiohttp.ClientSession() as session:
async with session.post(
HF_API_URL,
headers=HEADERS,
json=payload,
timeout=30
) as response:
if response.status != 200:
error = await response.text()
raise Exception(f"HF API error {response.status}: {error}")
result = await response.json()
return result[0]['generated_text']
payload = {
"inputs": prompt,
"parameters": {
"temperature": 0.3,
"max_new_tokens": 1024,
"return_full_text": False
}
}
response = await query_hf_api(payload)
Error:
<ClientResponse(https://api-inference.huggingface.co/models/meta-llama/Mistral-7B-Instruct-v0.3) [404 Not Found]>
<CIMultiDictProxy(
'Content-Type': 'text/plain; charset=utf-8',
'Content-Length': '9',
'Connection': 'keep-alive',
'Date': 'Mon, 07 Jul 2025 11:29:49 GMT',
'Access-Control-Allow-Credentials': 'true',
'X-Powered-By': 'huggingface-moon',
'cross-origin-opener-policy': 'same-origin',
'Referrer-Policy': 'strict-origin-when-cross-origin',
'x-request-id': 'Root=1-686bafad-49b4c71a2c85be1316d2847d',
'Vary': 'origin, access-control-request-method, access-control-request-headers',
'Access-Control-Allow-Origin': '*',
'Access-Control-Expose-Headers': 'X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Linked-Size,X-Linked-ETag,X-Xet-Hash',
'X-Cache': 'Error from cloudfront',
'Via': '1.1 9d889af515a5cd86a11x05f7befed532.cloudfront.net (CloudFront)',
'X-Amz-Cf-Pop': 'DEL51-P5',
'X-Amz-Cf-Id': 'x7JSW98lzRvThw5yEvCt4-LzVxo6vxv4jxpWkvBHrHQQm8ZoOlQVhQ=='
)>
Metadata
Metadata
Assignees
Labels
No labels