API documentation
OpenAI-compatible interface to 16 large language models from 5 upstream providers.
5-minute quickstart
Get from zero to a successful API call in five minutes. No SDK install required.
Before you copy any code: get the Base URL right
Every API request goes to this base — the trailing /v1 is required, not optional:
- Base URL:
https://api.houjiayan.com/v1 - Chat:
POST https://api.houjiayan.com/v1/chat/completions - Model list:
GET https://api.houjiayan.com/v1/models
OpenAI-compatible clients disagree on this one field: the official SDKs, Cherry Studio and OpenClaw need the full https://api.houjiayan.com/v1; NextChat takes the bare domain and appends /v1 itself. Symptom of a wrong value: HTTP 200 with an HTML page instead of JSON — the most common integration failure reported by our integrators. Per-client values are spelled out in Client setup recipes below.
1. Create an account
Go to api.houjiayan.com/register. You'll need an email address; we send a verification link. New accounts receive a ¥6.6 (approx. $1.00) sign-up bonus — no fixed expiry; it stays valid as long as your account is active.
2. Generate an API key
In the dashboard, click "Add a new token". Give it a name (e.g. "dev-laptop") and copy the key — it's shown only once.
3. Make your first call
Run the curl below. You should see a JSON response with a 'Hello!' message in the assistant role.
curl https://api.houjiayan.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{"role": "user", "content": "Hello"}
]
}' Base URL
https://api.houjiayan.com/v1 Authentication
Pass your API key as a Bearer token in the Authorization header. Never expose your key in client-side code or public repositories.
Authorization: Bearer sk-hjy-... Client setup recipes
Copy-paste configuration for popular OpenAI-compatible clients. Only the Base URL field differs per client — the exact value is noted for each.
Python (openai SDK)
base_url takes the full URL including /v1.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.houjiayan.com/v1" # ← include /v1
) Node.js (openai SDK)
baseURL takes the full URL including /v1.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.houjiayan.com/v1" // ← include /v1
}); LangChain (ChatOpenAI)
Pass base_url with the full URL including /v1 (older LangChain versions use the openai_api_base parameter).
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="kimi-k2.6",
api_key="YOUR_API_KEY",
base_url="https://api.houjiayan.com/v1" # older LangChain: openai_api_base=...
)
print(llm.invoke("Hello").content) Cherry Studio
Add an OpenAI-compatible provider. The API host field takes the full URL including /v1.
Provider type : OpenAI (OpenAI-compatible)
API host : https://api.houjiayan.com/v1 ← include /v1
API key : sk-hjy-...
Models : add by ID — e.g. kimi-k2.6, deepseek-v4-flash NextChat / ChatGPT-Next-Web
The custom endpoint (BASE_URL) takes the bare domain WITHOUT /v1 — NextChat appends /v1/chat/completions itself. Entering .../v1 here double-prefixes the path and requests fail.
Custom endpoint (BASE_URL) : https://api.houjiayan.com ← bare domain, NO /v1
API key : sk-hjy-...
Custom models : +kimi-k2.6,+deepseek-v4-flash OpenClaw
baseUrl takes the full URL including /v1 — OpenClaw does not append it. A domain-only value hits the gateway's web console and returns HTTP 200 with an HTML page instead of JSON; if you see that symptom, check this field first.
baseUrl : https://api.houjiayan.com/v1 ← include /v1 (not auto-appended)
apiKey : sk-hjy-...
model : kimi-k2.6 (or any ID from the models table) cURL
No base URL field — call the full endpoint paths directly.
curl https://api.houjiayan.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{"role": "user", "content": "Hello"}
]
}' Available models
All models support the OpenAI Chat Completions schema. Pricing is per million tokens (1M tokens), set in CNY (¥) and shown here in USD ($, weekly reference rate). Input price is for prompt tokens; output price is for generated tokens. The four Kimi models are also in the smart routing pool — POST to /v1/auto/chat/completions with "model": "auto" and the gateway may pick a Kimi model automatically when it leads the quality band.
| Model | Provider | Context | Input | Output | Best for |
|---|---|---|---|---|---|
deepseek-v4-pro | DeepSeek | 256K | $0.44 | $0.88 | Flagship reasoning, complex analysis, research |
deepseek-v4-flash | DeepSeek | 1M | $0.15 | $0.29 | Fast reasoning, chatbots, content generation |
qwen3.7-max | Alibaba Cloud | 256K | $1.35 | $4.04 | Flagship Qwen, translation, summarization |
qwen3.7-plus | Alibaba Cloud | 128K | $0.29 | $1.18 | Code generation, technical writing |
qwen3.7-max-us | Alibaba Cloud | 256K | $1.37 | $4.12 | US-region route of the Qwen flagship — same capability, lower price |
qwen3.7-plus-us | Alibaba Cloud | 128K | $0.31 | $1.21 | US-region route of qwen3.7-plus — everyday workloads at a lower price |
qwen3.6-max-preview | Alibaba Cloud | 256K | $1.26 | $7.58 | Next-gen Qwen flagship preview, translation, summarization. No authoritative benchmark yet — manual selection only, excluded from smart routing |
qwen3.6-plus | Alibaba Cloud | 128K | $0.28 | $1.69 | Next-gen Qwen mid-tier, code generation, technical writing. No authoritative benchmark yet — manual selection only, excluded from smart routing |
qwen3.5-ocr | Alibaba Cloud | 32K | $0.07 | $0.29 | Document OCR, image text extraction. No authoritative benchmark yet — manual selection only, excluded from smart routing |
MiniMax-M3 | MiniMax | 1M | $0.30~0.60 | $1.20~2.40 | Flagship multimodal, vision + text — tiered by context (≤512K / 512K–1M) |
MiniMax-M2.7 | MiniMax | 256K | $0.15 | $0.62 | Tool calling, agent systems, multi-step planning |
doubao-seed-code | ByteDance | 64K | $0.18 | $1.19 | Code generation specialist, completion, debugging |
kimi-k3 | Moonshot | 1M | $2.95 | $14.75 | Flagship all-round, top-tier coding, long-context agents |
kimi-k2.7-code | Moonshot | 256K | $0.91 | $3.79 | Dedicated coding, repo-level edits, debugging |
kimi-k2.7-code-highspeed | Moonshot | 256K | $1.83 | $7.58 | High-speed coding, low-latency dev loops |
kimi-k2.6 | Moonshot | 256K | $0.91 | $3.79 | High-value general purpose, everyday chat + writing |
Pin a model, or let the gateway route
Two ways to set the model field. (1) Pin an exact ID from the table above (e.g. "model": "kimi-k2.6") — the request goes straight to that model via /v1/chat/completions. (2) Smart routing: POST to /v1/auto/chat/completions with "model": "auto" and an optional "preference": "quality" (default — best result), "balanced" (cost-aware inside the quality band) or "cost" (cheapest, quality not guaranteed). Routed responses include a routing_decision block so you can audit every choice.
curl https://api.houjiayan.com/v1/auto/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"preference": "balanced",
"messages": [{"role": "user", "content": "Hello"}]
}' Code examples
cURL
curl https://api.houjiayan.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{"role": "user", "content": "Hello"}
]
}' Python (openai SDK)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.houjiayan.com/v1"
)
response = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content) Node.js (openai SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.houjiayan.com/v1"
});
const response = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [{ role: "user", content: "Hello" }]
});
console.log(response.choices[0].message.content); Streaming response (SSE)
Set stream: true to receive tokens as they are generated. Each chunk is a server-sent event with a delta field.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.houjiayan.com/v1"
)
stream = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Write a haiku about APIs"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="") Function calling
Most models support OpenAI-compatible tool calling. Define your tools in the tools array; the model returns structured tool_calls that you execute and feed back as tool role messages.
from openai import OpenAI
import json
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.houjiayan.com/v1")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather in a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"}
},
"required": ["city"]
}
}
}]
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "What's the weather in Hohhot?"}],
tools=tools
)
tool_call = response.choices[0].message.tool_calls[0]
print(f"Call: {tool_call.function.name}({tool_call.function.arguments})") Error codes
-
401Invalid or missing API key. Check the Authorization header and that the key has not been revoked. -
402Insufficient balance. Top up via the dashboard, or request a refund if the 24h window applies. -
403API key does not have access to this model, or account is suspended for Terms violation. -
404Model name is unknown. Use /v1/models to list all available models. -
413Request payload too large. Reduce prompt size or use a model with larger context window. -
429Rate limit hit. The gateway auto-retries on a different upstream where possible. If persistent, see Rate limits below. -
500/502/503/504Upstream provider error. The gateway returns the error from the source. Try a different model, or retry with exponential backoff. -
529All upstream providers are overloaded. The gateway could not complete the request. Retry after 30 seconds.
Rate limits
Per-user limits: 60 requests/minute, 100K tokens/minute (input + output combined). The gateway auto-failover ensures that if one upstream returns 429, traffic shifts to another provider where available. If you need higher limits, email support@houjiayan.com with your use case.
Concurrent requests
Up to 5 concurrent in-flight requests per API key. Exceeding this returns 429. For batch workloads, use the /v1/batch endpoint (coming Q4 2026).
Best practices
- Always set explicit max_tokens to avoid runaway costs (especially on reasoning models).
- Use stream: true for user-facing chat UIs to reduce perceived latency.
- Cache identical prompts for 5-60 seconds at the application layer to reduce token spend on retries.
- Implement exponential backoff with jitter for 429 and 5xx errors.
- Never put your API key in client-side code. Proxy through your backend.
- For long documents, prefer MiniMax-M3 or deepseek-v4-flash (1M context) over chunking.
Need help?
Email support@houjiayan.com or open a ticket in the dashboard. We respond within 24 hours on business days.