Call the shared endpoint
Get a key, add credit, and call open models on denv's shared OpenAI-compatible endpoint with curl or the OpenAI Python SDK, streaming included. What 402 and 429 mean, and how usage is counted.
denv runs open models on its own GPUs behind one OpenAI-compatible endpoint:
https://api.run.denv.ai/v1
You pay per token from a prepaid balance. Prices are on the pricing page. You do not need GPUs, a cloud account or a deployment.
1. Get a key and add credit
In the console, open Billing:
- Under Add credit, pay by card, from $10 to $5,000. Payment happens on Stripe's page.
- Under Inference keys, create a key. It starts with
dsk_and is shown once. Copy it.
A key works within about ten seconds of being created. It can call models and nothing else; it cannot manage your team.
export DENV_INFERENCE_KEY=dsk_...
2. Call it with curl
curl https://api.run.denv.ai/v1/chat/completions \
-H "Authorization: Bearer $DENV_INFERENCE_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen/qwen3.8-27b", "messages": [{"role": "user", "content": "Hello"}]}'
List the models the endpoint serves:
curl https://api.run.denv.ai/v1/models
3. Call it with the OpenAI Python SDK
pip install openai
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.run.denv.ai/v1", api_key=os.environ["DENV_INFERENCE_KEY"])
reply = client.chat.completions.create(
model="qwen/qwen3.8-27b",
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)
print(reply.usage)
4. Stream
Set stream and read tokens as they arrive:
stream = client.chat.completions.create(
model="qwen/qwen3.8-27b",
messages=[{"role": "user", "content": "Write a haiku about GPUs."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\n", chunk.usage)
With curl, add "stream": true to the body and -N to the command. The answer is server-sent events, as with OpenAI.
stream_options.include_usage is optional. Without it, a stream is metered the same way; you just do not see the usage chunk.
Errors
| Status | Meaning | What to do |
|---|---|---|
401 |
The key is missing, wrong or revoked. | Check the Authorization: Bearer dsk_... header. |
402 |
Your balance is used up. | Add credit in Billing, or turn on automatic top-up there so it does not happen again. |
404 |
The model is not served here. | GET /v1/models lists the model ids. |
429 |
The model is at capacity right now. | Wait for the Retry-After header (seconds) and retry. We answer early rather than queue your request. |
Errors use OpenAI's shape, {"error": {"type": ..., "message": ...}}, so OpenAI SDKs raise their usual exceptions.
How usage is counted
Each request is counted from the token usage the engine reports for it:
- Input: prompt tokens not served from the prefix cache.
- Cached input: prompt tokens served from the prefix cache. When the same prompt prefix comes back soon after, the engine reuses its work.
- Output: completion tokens, including any reasoning tokens.
Cost is each count times its price per token. Billing shows usage per day and model for the last 30 days, with its cost. Charges come out of your credit within seconds of each request, so the balance can go slightly below zero after a burst of traffic; the next request after that gets 402.
What is kept from each request, and what is not, is in the data policy.