Spaces:
Running
Running
Upload 58 files
Browse files- test_models.py +17 -0
test_models.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import httpx
|
| 2 |
+
import asyncio
|
| 3 |
+
|
| 4 |
+
async def fetch_models():
|
| 5 |
+
url = 'https://openrouter.ai/api/v1/models'
|
| 6 |
+
async with httpx.AsyncClient() as client:
|
| 7 |
+
resp = await client.get(url)
|
| 8 |
+
if resp.status_code == 200:
|
| 9 |
+
data = resp.json()
|
| 10 |
+
free_models = [m['id'] for m in data['data'] if 'free' in m['id']]
|
| 11 |
+
print('Free Models:')
|
| 12 |
+
for m in free_models:
|
| 13 |
+
print(m)
|
| 14 |
+
else:
|
| 15 |
+
print('Failed to fetch')
|
| 16 |
+
|
| 17 |
+
asyncio.run(fetch_models())
|