Developer Docs
Xuanlin Q&A offers an OpenAI-compatible endpoint for scholarly Yijing and Bazi answers grounded in an extensive classical library.
Endpoint
POST https://api.xuanlinyi.com/v1/chat/completions
OpenAI-compatible. Ask in Chinese, English, German, Spanish, Japanese, Korean or Russian — answered in your language.
Authentication
Send your API key as a bearer token:
Authorization: Bearer sk-xl-xxxxxxxxxxxxxxxx
Create keys under Developer Features in My Account.
Example
curl -X POST https://api.xuanlinyi.com/v1/chat/completions \
-H "Authorization: Bearer sk-xl-xxxx" \
-H "Content-Type: application/json" \
-d '{"model":"xuanlin-qa","messages":[{"role":"user","content":"How to use the Jianlu structure?"}]}'
Parameters
| Param | Description |
|---|---|
| messages | Required. Last user message is the question. |
| max_tokens | Optional, default 1800, max 4096. Funds are reserved to this ceiling and unused credit is released at settlement. |
| temperature | Optional, default 0.15, range 0-1.5. |
| stream | Streaming not supported yet. |
Response
Standard OpenAI format, plus a xuanlin field with the answer language, domain, source count, calendar-calculation status, cost and remaining balance. Retrieved library excerpts are not exposed by the API.
Errors
| HTTP | code | Meaning |
|---|---|---|
| 401 | invalid_api_key | Missing or invalid key |
| 402 | insufficient_balance | Balance too low |
| 429 | rate_limited | Rate limited (60 req/min/key) |
| 502 | upstream_error | Generation service unavailable |
Billing
| Item | Rate |
|---|---|
| Anonymous web Q&A | Free. 5 queries per browser visitor per day; the network address has only a higher anti-abuse safety ceiling. |
| Signup credit | ¥10 free credit on registration, for web Q&A and API calls. |
| Web Q&A (signed-in) | ¥0.015 / 1K input and ¥0.060 / 1K output; capped at ¥0.30 for Standard or ¥0.60 for Deep. |
| API calls | Same token rates, without the web tier cap; deducted by actual usage. |
| Out of balance | Web Q&A falls back to the free daily quota; API returns HTTP 402. |
| Top-up | Secure Stripe payment, minimum ¥10. All permissions restore automatically after top-up. |
Formula: raw cost (CNY) = input_tokens / 1000 × 0.015 + output_tokens / 1000 × 0.060. Web Q&A then applies the selected tier cap; API calls use the raw cost.
Example: a typical Q&A (~4,000 input + 800 output tokens) costs about ¥0.11. The ¥10 signup credit covers roughly 25–30 queries.
Balance: check your balance, usage and spending in My Account. More questions — see the FAQ.
Copyright
Answers are compiled from publicly available sources. To request takedown, use the Copyright & Takedown page.