Spaces:
Running
Running
Use free open models via Hugging Face Inference Providers with Sign in with Hugging Face; credit DevRubenArevalo
e9c63c4 Download test_api.py from mackenzietechdocs/HealixPath: direct link, hf CLI and curl.
- Browser
- Download file 936 Bytes
-
https://huggingface.co/spaces/mackenzietechdocs/HealixPath/resolve/main/test_api.py
- Command line
-
hf download hf://spaces/mackenzietechdocs/HealixPath/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/mackenzietechdocs/HealixPath/resolve/main/test_api.py
936 Bytes
| #!/usr/bin/env python3 | |
| """Dev-only smoke test: calls the HealixPath model with a token you supply via HF_TOKEN. | |
| The app itself never reads HF_TOKEN; visitors sign in with Hugging Face instead. | |
| """ | |
| import os | |
| from huggingface_hub import InferenceClient | |
| model = os.getenv("HEALIXPATH_MODEL", "openai/gpt-oss-20b") | |
| token = os.getenv("HF_TOKEN") | |
| print(f"Model: {model}") | |
| print(f"HF_TOKEN set: {bool(token)}") | |
| if token: | |
| try: | |
| result = InferenceClient(api_key=token).chat_completion( | |
| model=model, | |
| messages=[{"role": "user", "content": "Say hello"}], | |
| max_tokens=100, | |
| ) | |
| print("API call successful") | |
| print(f"Response: {result.choices[0].message.content}") | |
| except Exception as e: | |
| print(f"API error: {type(e).__name__}") | |
| print(f"Message: {e}") | |
| else: | |
| print("Set HF_TOKEN (needs the 'Make calls to Inference Providers' permission) to run this check.") | |