Product and API documentation
This domain serves product information and technical documentation only — there is no live API endpoint. Below is the specification of our OpenAI-compatible interface so you can evaluate it. The team provides the production base URL, key and quota at onboarding.
Overview
- OpenAI Chat Completions compatible: same paths, same fields, same error shapes.
- One endpoint for Llama, Qwen and DeepSeek, including V4.1 Flash with 1M context.
- Streaming passthrough, automatic upstream failover, token-based billing.
The
HNS_BASEbelow is a placeholder; replace it with the base URL the team provides. This marketing domain does not answer/v1/*.
Authentication
Every request carries a bearer token once you are connected:
Authorization: Bearer sk-hns-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA missing or malformed token returns 401, and a revoked key returns 401 as well. The server stores only the key’s SHA-256 hash and cannot recover the plaintext; if you lose it, create a new one.
Request format
POST /v1/chat/completions
curl $HNS_BASE/v1/chat/completions \
-H "Authorization: Bearer $HNS_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
"messages": [
{"role": "system", "content": "你是一位精簡的助理。"},
{"role": "user", "content": "用三點說明 edge computing。"}
],
"max_tokens": 256,
"temperature": 0.7
}'GET /v1/models
curl $HNS_BASE/v1/models \
-H "Authorization: Bearer $HNS_KEY"Each model in the response includes pricing.input and pricing.output (USD / 1M tokens) and context_window.
SDK setup
The official OpenAI SDK works as-is — just change the base URL and key.
Python
from openai import OpenAI
client = OpenAI(
base_url=HNS_BASE + "/v1",
api_key="sk-hns-...",
)
resp = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
print(resp.usage)Node / TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: HNS_BASE + "/v1",
apiKey: process.env.HNS_KEY,
});
const resp = await client.chat.completions.create({
model: "Qwen/Qwen2.5-72B-Instruct",
messages: [{ role: "user", content: "你好" }],
});Streaming
Add "stream": true and the response is text/event-stream. The gateway forwards chunk by chunk without buffering the whole answer; the final chunk carries usage, followed by data: [DONE].
curl -N $HNS_BASE/v1/chat/completions \
-H "Authorization: Bearer $HNS_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-ai/DeepSeek-V3",
"messages": [{"role": "user", "content": "寫一個 hello world"}],
"stream": true
}'The gateway adds
stream_options.include_usagefor you, so you do not need to; usage is still billed.
Models and pricing
Prices are reference USD rates per 1M tokens, with input and output billed separately. The list the team provides at onboarding is authoritative.
| Model | Context | Input / 1M | Output / 1M |
|---|---|---|---|
| meta-llama/Llama-3.3-70B-Instruct-Turbo Llama 3.3 70B Instruct · General chat and writing | 131,072 | $0.10 | $0.32 |
| meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo Llama 3.1 8B Instruct Turbo · Fastest and cheapest — ideal for classification and extraction | 131,072 | $0.02 | $0.04 |
| Qwen/Qwen2.5-72B-Instruct Qwen2.5 72B Instruct · Stable across Chinese and other languages | 32,768 | $0.36 | $0.40 |
| deepseek-ai/DeepSeek-V3 DeepSeek V3 · Reasoning and code | 163,840 | $0.32 | $0.89 |
| deepseek-ai/DeepSeek-V4.1-Flash-1017 DeepSeek V4.1 Flash · 1M context for long documents and agents | 1,048,576 | $0.20 | $0.60 |
| Qwen/Qwen3-32B Qwen3 32B · Newer Qwen for reasoning and tool calls | 40,960 | $0.08 | $0.28 |
Error codes
Error shapes match OpenAI:
{
"error": {
"message": "Missing or invalid API key.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}| HTTP | code | Meaning |
|---|---|---|
| 400 | invalid_json / missing_model / model_not_found | The request body is invalid |
| 401 | invalid_api_key | No key, or the key is invalid or revoked |
| 402 | quota_exceeded | Monthly quota exhausted; resets on the 1st at 00:00 UTC |
| 429 | rate_limit_exceeded | Per-minute request limit exceeded |
| 502 | upstream_500 … | Primary and backup upstreams both failed (the code carries the upstream status) |
| 503 | upstream_not_configured | No provider is currently configured for this model |
| 504 | upstream_timeout | The upstream sent no response headers within 30 seconds |
Quota and rate limits
- Every key has
monthly_usd_quota(USD per month) andrpm_limit(requests per minute). - Usage accrues per UTC calendar month and resets at the start of the month.
- When the quota is exhausted the gateway returns
402;monthly_usd_quota = 0disables the key (immediate 402). - Exceeding the rate returns
429withRetry-After. - The
x-hns-providerresponse header shows which provider served the request, andx-hns-cost-usdshows its cost.
Bring your own key (BYOK)
If you already have a DeepInfra or Together key, send it with the request and it goes straight upstream with no service fee (token usage is still recorded).
Authorization: Bearer sk-hns-...
X-Upstream-Provider: deepinfra # or together
X-Upstream-Key: your-upstream-keyIn BYOK mode
x-hns-cost-usdis0.000000; the usage record is still written so you can reconcile token counts.
To discuss onboarding, request a key or check your quota, contact us.