01Quick start
- Sign up, sign in to the console, and create an API key (starting with sk-) on the Keys page.
- Set the endpoint to
https://ai.lingapp.io/v1and the model to a model ID, for exampleflash. - Run the example below. Set
streamto true for streaming output.
The examples use the OpenAI format; requests and responses match OpenAI Chat Completions.
from openai import OpenAI
client = OpenAI(
api_key="sk-YOUR_API_KEY",
base_url="https://ai.lingapp.io/v1",
)
stream = client.chat.completions.create(
model="flash",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-YOUR_API_KEY",
baseURL: "https://ai.lingapp.io/v1",
});
const stream = await client.chat.completions.create({
model: "flash",
messages: [{ role: "user", content: "Hello" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}curl https://ai.lingapp.io/v1/chat/completions \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flash",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'02Endpoints & auth
For the OpenAI SDK, the base_url ends at /v1. For the Anthropic SDK, use just the domain; the SDK appends /v1/messages itself. All keys share your account balance, and we recommend a separate key per project. Never put your key in front-end web code or a public repository.
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat (OpenAI format), with streaming, function calling and image input |
| POST | /v1/messages | Chat (Anthropic format), works with tools such as Claude Code |
| GET | /v1/models | List the models available to your key |
| POST | /v1/images/generations | Image generation (model: lingshu-image) |
| POST | /v1/images/edits | Image edits (model: lingshu-image) |
03Anthropic format
Matches the Anthropic Messages API. Send the x-api-key and anthropic-version headers.
from anthropic import Anthropic
client = Anthropic(
api_key="sk-YOUR_API_KEY",
base_url="https://ai.lingapp.io", # the SDK appends /v1/messages automatically
)
message = client.messages.create(
model="flash",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "sk-YOUR_API_KEY",
baseURL: "https://ai.lingapp.io", // the SDK appends /v1/messages automatically
});
const message = await client.messages.create({
model: "flash",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content[0].text);curl https://ai.lingapp.io/v1/messages \
-H "x-api-key: sk-YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "flash",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'04Streaming
Add "stream": true to your request and the reply streams back in chunks via SSE (server-sent events), so you see text right away instead of waiting for the full answer.
- OpenAI format: each chunk is a
chat.completion.chunk, ending withdata: [DONE]. - Just before the stream ends, a usage chunk is sent with an empty
choices; its token counts are what you're billed for. This is turned on automatically, with no extra setup. - Anthropic format: returned as a Messages event stream (message_start, content_block_delta, message_stop and so on), which the official SDKs parse directly.
05Models
| Name | API ID | Input / Cached / Output | Context | Max output |
|---|---|---|---|---|
| Uncensored | ||||
| DeepSeek V4.1 Flash Uncensored | flash | $0.148 / $0.035 / $0.38 | 1M | 128K |
| GLM 5.3 Flash Uncensored | plus | $0.20 / $0.05 / $0.80 | 1M | 128K |
| GLM 5.3 Uncensored | pro | $1.80 / $0.28 / $3.60 | 1M | 128K |
| Kimi K3.1 Pro Uncensored | kimi-pro | $3.50 / $0.40 / $7.00 | 1M | 128K |
| Original | ||||
| DeepSeek V4.1 Flash OriginalLimited-time price · same rate all day | flash-std | $0.083 / $0.005 / $0.34 | 1M | 128K |
| GLM 5.3 Flash Original | plus-std | $0.104 / $0.0442 / $0.48 | 1M | 128K |
| Kimi K3.1 Pro OriginalLimited-time price · same rate all day | kimi | $1.00 / $0.18 / $5.00 | 1M | 128K |
| MiniMax M3.1 Flash | minimax-flash | $0.10 / $0.01 / $0.40 | 1M | — |
| Lingshu Image V5.5 (Uncensored) | lingshu-image | $0.13 / image | — | 1K output |
Chat model units: USD per million tokens, in the order input / cached input / output. Image generation is billed per image; see the Image API section below. Details are on the models page.
06Image API
Model ID lingshu-image (Lingshu Image V5.5, uncensored). Use your usual key; the base URL is still https://ai.lingapp.io/v1. One image per request, about 20 seconds, 1K resolution. The default response is base64 (b64_json); we do not host images. If you set response_format=url, you get a data: URL, not a publicly hosted link.
Price: $0.13 per image. For edits, $0.05 is added from the 2nd reference image. Failed or safety-blocked requests are not billed. Do not call /v1/chat/completions for this model.
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-YOUR_API_KEY",
base_url="https://ai.lingapp.io/v1",
)
# 生图
r = client.images.generate(
model="lingshu-image",
prompt="一只坐在窗边的橘猫,阳光,写实",
size="1024x1024",
response_format="b64_json",
)
open("cat.webp", "wb").write(base64.b64decode(r.data[0].b64_json))
# 改图(把原图传进去)
r2 = client.images.edit(
model="lingshu-image",
image=open("cat.webp", "rb"),
prompt="改成夜晚,窗外下着雨",
response_format="b64_json",
)
import OpenAI from "openai";
import { writeFile, readFile } from "fs/promises";
import { toFile } from "openai";
const client = new OpenAI({
apiKey: "sk-YOUR_API_KEY",
baseURL: "https://ai.lingapp.io/v1",
});
const r = await client.images.generate({
model: "lingshu-image",
prompt: "一只坐在窗边的橘猫,阳光,写实",
size: "1024x1024",
response_format: "b64_json",
});
await writeFile("cat.webp", Buffer.from(r.data[0].b64_json, "base64"));
const r2 = await client.images.edit({
model: "lingshu-image",
image: await toFile(await readFile("cat.webp"), "cat.webp", { type: "image/webp" }),
prompt: "改成夜晚,窗外下着雨",
response_format: "b64_json",
});
curl https://ai.lingapp.io/v1/images/generations \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "lingshu-image",
"prompt": "一只坐在窗边的橘猫,阳光,写实",
"size": "1024x1024",
"response_format": "b64_json"
}'Optional size: use size values such as 1024x1024, 1024x1792 or 1792x1024, or pass aspect_ratio (1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9). Edits also accept JSON, with the image as base64 in the image or images field.
07Error codes
Errors return an HTTP status code and a JSON error body.
| Status | code / message | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_request | Malformed request | Check that the JSON is valid and includes the model and messages fields. |
| 401 | invalid_token | Key missing, invalid or disabled | Check the key in your request headers, and make sure it's enabled in the console. |
| 402 / 403 | insufficient_quota | Insufficient balance, or the key can't use this model | If your balance is low, top up in the console. Also make sure the model name is a listed model ID (see the model table above). |
| 429 | rate_limited | Too many requests | Wait the number of seconds in the Retry-After header, then retry. Contact support if you need higher concurrency. |
| 500 | temporarily_unavailable | Internal server error | You were not charged. Wait a few seconds and retry. |
| 502 / 503 | temporarily_unavailable | Service temporarily busy or switching routes | You were not charged. Wait as indicated by Retry-After, then retry; if it keeps failing, back off with growing intervals (exponential backoff). |
{
"error": {
"message": "Invalid token",
"type": "lingshu_error",
"code": "invalid_token"
}
}08Rate limits
Request rates are limited per source IP; IPv6 addresses are grouped by prefix. Over the limit, you'll get 429 (rate_limited); see the error code table above for what to do.
| Scope | Limit | Description |
|---|---|---|
| Sign-in endpoints | 10 / minute | Includes sign-in and other auth requests |
| Chat endpoints | 40 / minute | Online chat and chat API calls |
| All endpoints combined | 900 / minute | Total requests from one IP across all endpoints |
09Common parameters
These are the most-used fields of the OpenAI-compatible chat endpoint (/v1/chat/completions). Pass any other parameter in the OpenAI format; if a model doesn't support it, it's ignored or returns an error.
| Parameter | Description |
|---|---|
| model | Model ID, required. For example flash. |
| messages | Array of chat messages, required. Each item has a role and content. |
| stream | When true, the response is streamed in chunks. |
| temperature | Sampling temperature; higher is more random. Optional. |
| max_tokens | Maximum output tokens for this reply. Optional; can't exceed the model's max output. |
| tools / tool_choice | Function calling (tool calling), same format as OpenAI. Optional. |
10Client setup
Any tool that lets you set a custom "API endpoint / Base URL" works with Lingshu, such as Cherry Studio, LobeChat, ChatBox, NextChat, Cursor, Cline, Continue, LangChain and Claude Code.
- OpenAI-compatible tools: set the endpoint to
https://ai.lingapp.io/v1(some clients take justhttps://ai.lingapp.ioand add /v1 themselves), use your sk- key, and set the model to a listed model ID such as flash. - Claude Code: set the environment variables
ANTHROPIC_BASE_URL=https://ai.lingapp.ioandANTHROPIC_AUTH_TOKEN=sk-YOUR_API_KEY, and set the model to a listed model ID such as flash.
Need help? Contact Telegram @lingshijie01.