Loading the Playground…
Loading the Playground…
Chat and compareOpen as its own page
Every answer shows what it cost, how long the first word took and how fast the model wrote. To compare, add up to three more models with “+ Add model”, or start from a set:
import json
import os
import requests
API = "https://api.gridpup.com/v1/ai"
HEADERS = {"Authorization": f"Bearer {os.environ['GRIDPUP_API_KEY']}"}
with requests.post(f"{API}/chat/completions", headers=HEADERS, stream=True, json={
"model": "openai/gpt-5-mini",
"messages": [
{
"role": "user",
"content": "Explain what a GPU does in one paragraph.",
},
],
"max_tokens": 2048,
"stream": True,
}) as r:
r.raise_for_status()
for line in r.iter_lines(decode_unicode=True):
if not line.startswith("data: ") or line == "data: [DONE]":
continue
chunk = json.loads(line[6:])
if chunk.get("choices"):
print(chunk["choices"][0]["delta"].get("content") or "", end="", flush=True)
if chunk.get("usage"):
print(f"\n\nCost: ${chunk['usage']['cost_usd']}")Set GRIDPUP_API_KEY to an API key with “Also use AI models”. Calls are paid from your balance at the same prices as here. All AI calls