接入文件
所有請求走 https://proxy.hidennseek.com。介面與 OpenAI Chat Completions 一致:相同路徑、相同欄位、相同錯誤格式。
快速開始
- 取得一把
sk-hns-開頭的 API key(只會顯示一次,請即時保存)。 - 把 SDK 的 base URL 指向
https://proxy.hidennseek.com/v1。 - 送出第一個
POST /v1/chat/completions。
認證
每個請求都要帶 bearer token:
Authorization: Bearer sk-hns-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx缺少或格式不符回 401,key 已撤銷同樣回 401。伺服器只保存 key 的 SHA-256 hash,無法查回明文;遺失請重新建立。
curl 範例
POST /v1/chat/completions
curl https://proxy.hidennseek.com/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 https://proxy.hidennseek.com/v1/models \
-H "Authorization: Bearer $HNS_KEY"回應內每個模型附有 pricing.input 與 pricing.output(USD / 1M tokens)與 context_window。
SDK 設定
官方 OpenAI SDK 直接可用,只要換 base URL 與 key。
Python
from openai import OpenAI
client = OpenAI(
base_url="https://proxy.hidennseek.com/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: "https://proxy.hidennseek.com/v1",
apiKey: process.env.HNS_KEY,
});
const resp = await client.chat.completions.create({
model: "Qwen/Qwen2.5-72B-Instruct",
messages: [{ role: "user", content: "你好" }],
});串流
加上 "stream": true,回應為 text/event-stream。閘道逐塊轉發,不緩衝整段回應;最後一個 chunk 帶 usage,之後是 data: [DONE]。
curl -N https://proxy.hidennseek.com/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
}'閘道會自動補上
stream_options.include_usage,所以你毋須自己加,用量一樣會入帳。
模型與定價
價格單位為美元,按每 1M token 計。清單以 GET /v1/models 為準。
| 模型 | Context | 輸入 / 1M | 輸出 / 1M |
|---|---|---|---|
| meta-llama/Llama-3.3-70B-Instruct-TurboLlama 3.3 70B Instruct · 通用對話、寫作 | 131,072 | $0.30 | $0.50 |
| meta-llama/Meta-Llama-3.1-8B-InstructLlama 3.1 8B Instruct · 最快、最平,適合分類與抽取 | 131,072 | $0.05 | $0.08 |
| Qwen/Qwen2.5-72B-InstructQwen2.5 72B Instruct · 中文與多語言表現穩定 | 32,768 | $0.45 | $0.60 |
| deepseek-ai/DeepSeek-V3DeepSeek V3 · 推理與程式碼 | 131,072 | $0.35 | $1.30 |
| mistralai/Mixtral-8x7B-Instruct-v0.1Mixtral 8x7B Instruct · MoE,長文摘要成本低 | 32,768 | $0.30 | $0.30 |
meta-llama/Llama-3.3-70B-Instruct-Turbo
Llama 3.3 70B Instruct · 通用對話、寫作
- Context
- 131,072
- 輸入 / 1M
- $0.30
- 輸出 / 1M
- $0.50
meta-llama/Meta-Llama-3.1-8B-Instruct
Llama 3.1 8B Instruct · 最快、最平,適合分類與抽取
- Context
- 131,072
- 輸入 / 1M
- $0.05
- 輸出 / 1M
- $0.08
Qwen/Qwen2.5-72B-Instruct
Qwen2.5 72B Instruct · 中文與多語言表現穩定
- Context
- 32,768
- 輸入 / 1M
- $0.45
- 輸出 / 1M
- $0.60
deepseek-ai/DeepSeek-V3
DeepSeek V3 · 推理與程式碼
- Context
- 131,072
- 輸入 / 1M
- $0.35
- 輸出 / 1M
- $1.30
mistralai/Mixtral-8x7B-Instruct-v0.1
Mixtral 8x7B Instruct · MoE,長文摘要成本低
- Context
- 32,768
- 輸入 / 1M
- $0.30
- 輸出 / 1M
- $0.30
GET /v1/models取得即時清單。幣別 USD・計費單位 1,000,000 tokens・價格可隨時調整。錯誤碼
錯誤格式與 OpenAI 一致:
{
"error": {
"message": "Missing or invalid API key.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}| HTTP | code | 意思 |
|---|---|---|
| 400 | invalid_json / missing_model / model_not_found | 請求內容有問題 |
| 401 | invalid_api_key | 未帶 key 或 key 無效/已撤銷 |
| 402 | quota_exceeded | 本月額度用完,下月 1 日 UTC 重設 |
| 429 | rate_limit_exceeded | 超過每分鐘請求上限 |
| 502 | upstream_500 等 | 主、備供應商都失敗(code 帶實際上游狀態碼) |
| 503 | upstream_not_configured | 該模型暫時沒有已設定的供應商 |
| 504 | upstream_timeout | 上游 30 秒內未回應標頭 |
額度與速率
- 每個 key 有
monthly_usd_quota(美元/月)與rpm_limit(每分鐘請求數)。 - 用量按 UTC 日曆月累計,月初歸零。
- 額度用完回
402;速率超過回429,並附Retry-After。 - 回應標頭
x-hns-provider顯示實際執行的供應商,x-hns-cost-usd顯示該次成本。
自帶上游 key(BYOK)
如你已有 DeepInfra 或 Together 的 key,可以自己帶上來,請求直接轉去上游,不計入本服務費用(仍會記錄 token 用量)。
Authorization: Bearer sk-hns-...
X-Upstream-Provider: deepinfra # 或 together
X-Upstream-Key: your-upstream-keyBYOK 模式下
x-hns-cost-usd為0.000000,用量紀錄仍會寫入,方便你核對 token 數。