Endpoint and authentication
The base URL for serverless inference is:lk_...) as a Bearer token. Most SDKs append the path for you, so you pass only the base URL above.
| Method | Path | Purpose |
|---|---|---|
POST | /chat/completions | Chat completions (streaming and non-streaming) |
POST | /embeddings | Text embeddings |
POST | /route | Score a prompt and get the recommended model (see Smart Routing) |
GET | /models | List the models currently available |
There is no legacy text
/completions endpoint. All text generation goes through /chat/completions using the messages format.Quickstart
- Python
- curl
Streaming
Setstream: true to receive tokens as they are generated. This is the recommended mode for anything user-facing or long-form, it lowers time-to-first-token and keeps the connection active for the full generation.
Timeouts and long-running requests
The platform allows a single request up to 300 seconds of generation time. Large context windows or long outputs on a non-streaming call can genuinely take minutes, so the most common source of “cut off” errors is a client-side timeout that fires before the response finishes, not the server. If you must run non-streaming for long generations, raise your client’s read timeout:Function calling and tools
All chat models support function / tool calling using the standard OpenAItools and tool_choice parameters.
A small number of models prefer to answer in text rather than call a tool when
tool_choice is left on "auto". If you find a model returning prose instead of a tool call, set tool_choice="required" to force it.Prompt caching
Prompt caching is automatic, there is nothing to enable. When consecutive requests share an identical leading prefix (for example a fixed system prompt or a large shared context), the cached portion is reused and billed at a reduced input rate. To benefit, keep the stable part of your prompt at the front and vary only the tail (the user’s latest message). Caching is best-effort, a request may or may not hit a warm cache depending on recent traffic. Cache hits are reported in the usage object:Reasoning models
Some models expose an explicit reasoning mode. For hybrid models that support it, toggle it withenable_thinking in the request body:
Embeddings
Text embeddings use the same base URL and key:Error handling
Errors are returned in the OpenAI-compatible shape, anerror object with message, type, and code:
error.type works the same way here as against the OpenAI API. Retry on 429 (rate limit) and 5xx / timeout responses with backoff.
Serverless vs dedicated
| Use case | Pick |
|---|---|
| Low-volume or spiky traffic, pay-per-request, no infra to manage | Serverless (this page) |
| Steady production traffic, predictable latency, your own model | Dedicated Inference |
| Let the platform choose a model per request by difficulty | Smart Routing |
Active Models
Browse the model IDs and context windows currently available.
Smart Routing
Automatically route each request to the right model.

