Spaces:
Sleeping
Sleeping
Download scratch/test_api_2.py from sardarbipul/hf_models: direct link, hf CLI and curl.
- Browser
- Download file 412 Bytes
-
https://huggingface.co/spaces/sardarbipul/hf_models/resolve/main/scratch/test_api_2.py
- Command line
-
hf download hf://spaces/sardarbipul/hf_models/scratch/test_api_2.py
-
curl -L -o test_api_2.py https://huggingface.co/spaces/sardarbipul/hf_models/resolve/main/scratch/test_api_2.py
412 Bytes
| import requests | |
| url = "https://huggingface.co/api/models?pipeline_tag=text-generation&limit=2" | |
| resp = requests.get(url) | |
| print("Status Code:", resp.status_code) | |
| try: | |
| print("Response JSON keys:", [k for k in resp.json()[0].keys()]) | |
| print("Example Model ID:", resp.json()[0]["id"]) | |
| except Exception as e: | |
| print("Error:", e) | |
| print("Response Text:", resp.text.encode('utf-8', errors='ignore')[:500]) | |