Developers
API Reference
Base URL https://api.layige.org. All inference endpoints require a bearer token from /auth/login. Requests are metered in credits; failed or degraded requests are not charged. No prompt or response text is ever stored server-side.
Authentication
POST
/auth/registerCreate an account. Rate-limited per IP.
curl -X POST https://api.layige.org/auth/register \
-H 'Content-Type: application/json' \
-d '{"email":"you@org.com","password":"at-least-8-chars"}'
# -> { "token": "<jwt>", "email_verified": false }POST
/auth/logincurl -X POST https://api.layige.org/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"you@org.com","password":"..."}'
# -> { "token": "<jwt>" }Chat
POST
/v1/chat/completions· Bearer JWTOpenAI-shaped. memory (client-side notes) and strategy are optional; omit strategy to auto-route.
curl -X POST https://api.layige.org/v1/chat/completions \
-H "Authorization: Bearer $JWT" -H 'Content-Type: application/json' \
-d '{
"messages": [{"role":"user","content":"Write a prime sieve in Python"}],
"strategy": "specialists",
"memory": { "notes": ["User prefers terse answers"] }
}'
# -> { "choices":[{"message":{"role":"assistant","content":"..."}}],
# "usage":{"credit_cost":10,"credits_remaining":90,"latency_ms":812.3} }Vision
POST
/v1/vision/analyze· Bearer JWTMultipart image upload (≤ 8 MB). Processed in memory, never stored.
curl -X POST https://api.layige.org/v1/vision/analyze \
-H "Authorization: Bearer $JWT" \
-F file=@chart.png -F prompt="Extract the data table"
# -> { "analysis": "...", "credit_cost": 2, "credits_remaining": 88 }Account & billing
GET
/v1/account· Bearer JWTcurl https://api.layige.org/v1/account -H "Authorization: Bearer $JWT"
# -> { "user_id": 1, "tier": "pro", "credits": 88 }POST
/billing/checkout· Bearer JWTReturns a Stripe Checkout URL to top up credits.
# -> { "checkout_url": "https://checkout.stripe.com/..." }System
GET
/v1/system/healthBackend liveness + per-GPU VRAM + air-gap flag. No auth.
GET
/v1/system/licenseOn-prem license validity (Ed25519 signature check).
Pricing (credits / successful request)
| Tier | Credits | What |
|---|---|---|
| low-gear | 1 | quick answers (fast model) |
| vision / grounding | 2 | image analysis, web lookup |
| pipeline | 5 | standard coding/answers |
| council | 10 | specialists, debate, vote, decompose |
Errors
| Status | Meaning |
|---|---|
| 401 | missing / invalid bearer token |
| 402 | insufficient credits |
| 403 | strategy not allowed on your tier (e.g. council on free) |
| 413 | payload too large |
| 429 | rate limit exceeded (per-IP or per-account) |