API Documentation
Authentication
Include your API key in the Authorization header:
Authorization: Bearer lnai_your_key_here
Get your API key from the Dashboard.
Base URL
https://platform-staging.lenout.com/v1
Chat Completions
OpenAI-compatible chat completion endpoint.
Request
POST /v1/chat/completions
Content-Type: application/json
Authorization: Bearer lnai_your_key_here
{
"model": "lenout-glm-4-flash",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"temperature": 0.7,
"max_tokens": 1024
}
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "lenout-glm-4-flash",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}
List Models
GET /v1/models
Authorization: Bearer lnai_your_key_here
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
| invalid_api_key | 401 | API key is invalid, revoked, or missing. |
| rate_limited | 429 | Too many requests. Check Retry-After header. |
| insufficient_balance | 402 | Not enough Lencon credits. Top up at lenout.com. |
| model_not_found | 404 | Requested model is not available. |
| invalid_request | 400 | Request body is malformed. |
| generation_failed | 502 | AI provider failed to generate a response. |
SDK Examples
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://platform-staging.lenout.com/v1",
api_key="lnai_your_key_here"
)
completion = client.chat.completions.create(
model="lenout-glm-4-flash",
messages=[{"role": "user", "content": "Hello!"}]
)
print(completion.choices[0].message.content)
Node.js (OpenAI SDK)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://platform-staging.lenout.com/v1',
apiKey: 'lnai_your_key_here'
});
const completion = await client.chat.completions.create({
model: 'lenout-glm-4-flash',
messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(completion.choices[0].message.content);
cURL
curl https://platform-staging.lenout.com/v1/chat/completions \
-H "Authorization: Bearer lnai_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "lenout-glm-4-flash",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Rate Limits
Default: 60 requests per minute per API key. Check the Retry-After header when rate limited.
Billing
Usage is billed in Lencon credits. 1 USD = 10 Lencon. Top up at lenout.com.
See pricing table on the home page for per-model costs.