Developer documentation

Build with the Lenout AI API.

Lenout AI provides one OpenAI-compatible chat endpoint, one Lenout-managed model, and pay-as-you-go billing from your shared Lencon wallet.

01 · Overview

What is Lenout AI Platform?

It is a developer API for sending chat-completion requests to the Lenout-managed model. It keeps the familiar OpenAI request shape, while authentication, usage, and Lencon billing stay inside your existing Lenout account.

⌁Compatible

Works with the OpenAI JavaScript and Python SDKs by changing the base URL.

✦Stable

Use one public model ID while Lenout manages the model service behind the endpoint.

◈Connected

Your Platform balance is the same Lencon wallet used by Lenout Community.

Current capability

The API supports non-streaming chat completions. Set stream to false or omit it.

02 · Quick start

Make your first request.

  1. 1
    Sign in to the Dashboard

    Your regular Lenout account works here—there is no separate developer sign-up.

  2. 2
    Create an API key

    Name the key for the app or environment that will use it. Copy it immediately; the full value is shown once.

  3. 3
    Store it on your server

    Put the key in an environment variable such as LENOUT_API_KEY.

  4. 4
    Send a chat-completion request

    Use https://platform-staging.lenout.com/v1 as the SDK base URL.

JavaScript · OpenAI SDK
import OpenAI from "openai"

const client = new OpenAI({
  baseURL: "https://platform-staging.lenout.com/v1",
  apiKey: process.env.LENOUT_API_KEY
})

const response = await client.chat.completions.create({
  model: "lenout-model",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Explain Lenout in one sentence." }
  ]
})

console.log(response.choices[0].message.content)
cURL
curl https://platform-staging.lenout.com/v1/chat/completions \
  -H "Authorization: Bearer lnai_your_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"lenout-model","messages":[{"role":"user","content":"Hello!"}]}'

03 · Authentication

Authenticate with a Bearer key.

Every billable API request must include your Lenout API key in the Authorization header. Dashboard sessions and API keys serve different purposes: your browser session manages keys, while a key authenticates your server-to-server requests.

Authorization: Bearer lnai_your_key_here
CredentialUse it forWhere it belongs
Lenout sessionDashboard, Community, walletSecure browser cookie managed by Lenout
lnai_… API key/v1/chat/completionsYour server or secret manager

04 · API reference

POST

/v1/chat/completions

Generate one assistant message from a list of system, user, and assistant messages.

Request body

FieldTypeRequiredDescription
modelstringYesA model ID from the table below.
messagesarrayYesAt least one message with role and string content.
temperaturenumberNoSampling temperature passed to the selected provider.
max_tokensnumberNoMaximum number of output tokens requested.
streambooleanNoStreaming is not available yet; omit this field or use false.

Example request

{
  "model": "lenout-model",
  "messages": [
    { "role": "system", "content": "Answer clearly and briefly." },
    { "role": "user", "content": "What can I build with this API?" }
  ],
  "temperature": 0.7,
  "max_tokens": 512
}

Example response

{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "created": 1787200000,
  "model": "lenout-model",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "You can build…" },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 42,
    "total_tokens": 66
  }
}
GET

/v1/models

Returns model IDs currently exposed by the Platform. This endpoint does not require an API key.

curl https://platform-staging.lenout.com/v1/models

05 · Models & pricing

Use the Lenout-managed model.

Prices are measured in Lencon per one million input or output tokens. The final charge is rounded up to a minimum of 1 Lencon per completed generation.

Model IDProviderInput / 1MOutput / 1MContext

Use GET /v1/models as the runtime source of available model IDs.

06 · Lencon & billing

One wallet across Lenout.

Lencon is Lenout's closed-loop usage credit. Your AI requests and Community activity draw from the same wallet, so a top-up made in the Platform is visible in Lenout Community as well.

Exchange$1 USD = 10 Lencon

Top-ups are one-time Stripe payments.

Packages$1 to $100

Select an available package in the Dashboard.

ChargingPer completed request

Usage is calculated from model input and output tokens.

Need more balance?

Open your Dashboard and choose “Top up Lencon”. Credits are applied after Stripe confirms payment.

Top up Lencon

07 · Errors

Handle errors by code and status.

Error responses include an error.code and human-readable error.message. Your app should branch on the code, not the message text.

StatusCodeWhat it means
400invalid_requestThe JSON body or one of its required fields is invalid.
400not_supportedThe requested feature, such as streaming, is not available.
401invalid_api_keyThe key is missing, invalid, expired, or revoked.
402insufficient_balanceThe shared Lencon wallet cannot cover the request.
404model_not_foundThe supplied model ID is not available.
429rate_limitedThe API key exceeded its per-minute request limit.
502generation_failedThe Lenout model service could not complete the generation.
Retry guidance

Retry temporary 429 and 502 responses with exponential backoff. Do not automatically retry validation, authentication, or insufficient-balance errors.

08 · Security

Keep every API key server-side.

1

Never put a key in frontend code. Browser bundles, mobile packages, and public repositories can expose secrets.

2

Use one key per app or environment. Separate keys make rotation and incident response safer.

3

Revoke a key immediately if it leaks. Create a replacement first, update your service, then revoke the old key.

4

Avoid logging credentials. Redact the Authorization header in application and proxy logs.

Ready for your first request?

Create a named key and copy it to your server secret store.

Open dashboard →