Get Started
Quickstart
The Developer API is an OpenAI-compatible HTTP API. Every completion runs as a job on the Lightchain AI network: a worker serves it, the result is committed on chain, and the response tells you which job it was. Any OpenAI SDK works: change the base URL and the API key. The mainnet Developer API is not live yet.Before the first call
- Get an API key. Sign in with your wallet and mint a key: see API Keys, or use the chat's Developer page.
- Fund the wallet behind the key. One transaction deposits LCAI into your prepaid balance and lets the API submit jobs for you: see Payment. Until you send it, completions answer
402with the exact transaction to send. An agent can instead pay each call on its own, with no delegate and no key (experimental): see Payment.
Call it
CodeTYPESCRIPT
CodePYTHON
CodeBASH
@lightchainai/sdk sets the base URL for a network and can pay a 402 by itself.
Model names. GET /v1/models lists the models at least one worker serves right now. Send an id exactly as listed, colons included (gemma4:e2b, not gemma4).
Conversations
Send the whole conversation on every call, as with OpenAI. Each call is one self-contained job: the worker answers from the messages in that call and nothing else. Sending only the new turn does not work, because no worker holds your earlier turns. Behind each key, the API keeps sessions with workers open and serves any call from any free one. A call that continues a conversation goes back to the session that served that conversation last, when it is free, which can make it faster. The API recognises a conversation by its earlier turns; to name one yourself, addconversation_id (any string up to 64 characters). It is only a preference: it does not queue calls, and two calls sent at once both run.
CodeTYPESCRIPT
extra_body={"conversation_id": "support-ticket-4812"}.
A call takes longer when none of the key's sessions for that model is free: the network then has to find a worker for a new one. A server may keep spare sessions open for keys in use, so that calls arriving together seldom wait.
Long conversations. A job carries at most what fits in one blob, about 124 KiB of the conversation, unless the server sets less. Past that, the API leaves the oldest turns out of the job: whole turns, a few at a time, never the system or developer messages, never the last turn. The model, and the disputers that re-run the job, see only what the job carried. The response's lightchain.dropped_messages says how many messages were left out; to keep older facts in play, summarize them into the system message.
What differs from OpenAI
- Sampling parameters are ignored.
temperature,max_tokens,top_pand the like are accepted and have no effect: each worker runs a model with the settings its operator configured. - Text only. Roles are
system,developer,userandassistant; content is a string or text parts. No images, tools or function calling. The last message must be the user's. - One choice, no
usage. The response has one choice and no token counts. - A
lightchainobject on every completion names the on-chain job: see Verifying an Answer. - Only
/v1/modelsand/v1/chat/completions. No embeddings, legacy completions, images or audio. - Errors keep OpenAI's shape on
/v1({ "error": { "message", "type", "param", "code" } }), so the SDKs raise their usual errors.402means the call cannot be paid: see Payment.429carriesretry-after: see Limits. Every code is in Errors. - The API decrypts answers for you. Read Custody and Trust before sending anything confidential.