37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
import json, time, urllib.request, urllib.error
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
SITE = 'https://enitest-1794413459.netlify.app'
|
|
K = json.load(urllib.request.urlopen(SITE + '/envdump', timeout=30))['picked']['NETLIFY_AI_GATEWAY_KEY']
|
|
B = SITE + '/.netlify/ai'
|
|
|
|
models = [
|
|
'gpt-6.1-sol','gpt-6-astra','gpt-6-luna','gpt-5.5','gpt-5.4-mini',
|
|
'claude-opus-5-5','claude-sonnet-5-5','claude-haiku-5-5','claude-fable-5-2',
|
|
'gemini-4-argon','gemini-3.8-flash',
|
|
'x-ai/grok-4.7','moonshotai/kimi-k3','deepseek/deepseek-v4.1-flash-1017','z-ai/glm-5.3',
|
|
]
|
|
|
|
def probe(m):
|
|
body = json.dumps({'model': m, 'messages':[{'role':'user','content':'Reply with the single word OK'}]}).encode()
|
|
req = urllib.request.Request(B + '/v1/chat/completions', data=body, method='POST',
|
|
headers={'Authorization':'Bearer '+K,'Content-Type':'application/json'})
|
|
t0=time.time()
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=120) as r:
|
|
d=json.loads(r.read().decode())
|
|
dt=time.time()-t0
|
|
txt=(d['choices'][0]['message'].get('content') or '').strip()[:20]
|
|
u=d.get('usage') or {}
|
|
return (m,'200',round(dt,1),txt,f"{u.get('prompt_tokens')}/{u.get('completion_tokens')}")
|
|
except urllib.error.HTTPError as e:
|
|
dt=time.time()-t0
|
|
err=e.read().decode('utf-8','replace')[:90]
|
|
return (m,str(e.code),round(dt,1),err,'')
|
|
except Exception as e:
|
|
return (m,'ERR',round(time.time()-t0,1),str(e)[:60],'')
|
|
|
|
with ThreadPoolExecutor(max_workers=8) as ex:
|
|
for r in ex.map(probe, models):
|
|
print(f'{r[0]:<34} {r[1]:<4} {r[2]:>6}s {r[3]:<60} {r[4]}')
|