The Python API example looks like it has been written by an LLM. You don't need to import json, you don't need to set the content type and it is good practice to use context managers ("with" statement) to release the connection in case of exceptions. Also, you don't gain anything by commenting variables with the name of the variable.<p>The following sample (probably) does the same thing and is almost half as short. I have not tested it because there is no signup (EDIT: I was mistaken, there actually is a "signup" behind the login link, which is Google or GitHub login, so the naming makes sense. I confused it with a previously more prominent waitlist link.)<p><pre><code> import requests
# Your Hypermode Workspace API key
api_key = "<YOUR_HYP_WKS_KEY>"
# Use the Hypermode Model Router API endpoint
url = f"https://models.hypermode.host/v1/chat/completions"
headers = {"Authorization": f"Bearer {api_key}"}
payload = {
"model": "meta-llama/llama-4-scout-17b-16e-instruct",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Dgraph?"},
],
"max_tokens": 150,
"temperature": 0.7,
}
# Make the API request
with requests.post(url, headers=headers, json=payload) as response:
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])</code></pre>
What I'm seeing with Brokk (<a href="https://brokk.ai" rel="nofollow">https://brokk.ai</a>) is that models are not really interchangeable for code authoring. Even with frontier models like GP2.5 and Sonnet 3.7, Sonnet is significantly better about following instructions ("don't add redundant comments") while GP2.5 has more raw intelligence. So we're using litellm to create a unified API to consume but the premise of "route your requests to whatever model is responding fastest" doesn't seem that attractive.<p>But OpenRouter is ridiculously popular so it must be very useful for other use cases!