Lingyuns speaks the OpenAI Chat Completions wire format. Point any SDK at our base URL, swap the key, and you are live in under a minute — no per-provider plumbing, no rewrite when a new model ships.
First request
Everything lives under a single base URL:
Base URL
https://api.lingyuns.com/v1
Authenticate with a bearer token. Keys carry the ly-sk- prefix, are shown exactly once when created, and are stored only as a hash on our side.
Never ship a key in client-side code. Proxy requests through your own backend and keep the key in a server-side environment variable. Revocation takes effect on the next request.
Listing models
Return the same shape as the OpenAI models endpoint, extended with context window and per-million pricing so you can route intelligently at runtime.
Usage accounting is identical for streaming and non-streaming requests — you are billed once per completion, not per frame.
Usage & billing
Credits are denominated in millions of tokens and drawn down as requests complete. Cost per request is computed from the model's input and output rates:
Example — 40M input and 12M output tokens on GPT-4o ($2.50 in / $10.00 out per million):
(40 * 2.50) + (12 * 10.00) = $220.00 → drawn from your credit balance
Daily and per-model breakdowns are available in your usage dashboard. GPU rentals are billed separately against the same balance — hourly plans accrue per running hour, monthly reservations commit 720 hours.
Error codes
Status
Type
Meaning
Action
400
invalid_request_error
Malformed body or unknown model id.
Fix the payload.
401
authentication_error
Missing, revoked or malformed key.
Issue a new key.
402
insufficient_credits
Balance exhausted.
Top up a token pack.
429
rate_limit_error
Too many requests for your tier.
Back off and retry.
529
upstream_overloaded
Provider capacity saturated.
Retry or route to a fallback model.
Errors use the standard envelope so existing retry logic keeps working: