Documentation Index
Fetch the complete documentation index at: https://docs.lucid.foundation/llms.txt
Use this file to discover all available pages before exploring further.
Run SDK
OpenAI-compatible inference (chat completions) and model listing
Operations
| Method | Description |
|---|
inference | Run inference (optionally streaming via SSE) |
chatCompletions | OpenAI-compatible chat completions |
Generated Reference
Overview
OpenAI-compatible inference (chat completions) and model listing
Available Operations
inference
Execute inference through the LucidLayer execution gateway. Supports both streaming (SSE) and non-streaming responses. A cryptographic receipt is generated for each successful inference.
Example Usage
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";
const raijinLabsLucidAi = new RaijinLabsLucidAi();
async function run() {
const result = await raijinLabsLucidAi.run.inference({});
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { runInference } from "raijin-labs-lucid-ai/funcs/runInference.js";
// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();
async function run() {
const res = await runInference(raijinLabsLucidAi, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("runInference failed:", res.error);
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|
request | models.InferenceRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.InferenceResult>
Errors
| Error Type | Status Code | Content Type |
|---|
| errors.ErrorResponse | 422 | application/json |
| errors.ErrorResponse | 500, 503 | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX | */* |
chatCompletions
x402-gated with dynamic pricing. If X402_ENABLED=true, requests without
a valid X-Payment-Proof header receive HTTP 402 with payment instructions.
Pricing is resolved per-model from the asset_pricing table.
Example Usage
import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";
const raijinLabsLucidAi = new RaijinLabsLucidAi();
async function run() {
const result = await raijinLabsLucidAi.run.chatCompletions({
body: {
model: "mistral-7b-instruct",
messages: [
{
role: "system",
content: "You are a helpful AI assistant.",
},
{
role: "user",
content: "Explain how MMR proofs work in one paragraph.",
},
],
maxTokens: 256,
temperature: 0.7,
},
});
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { runChatCompletions } from "raijin-labs-lucid-ai/funcs/runChatCompletions.js";
// Use `RaijinLabsLucidAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raijinLabsLucidAi = new RaijinLabsLucidAiCore();
async function run() {
const res = await runChatCompletions(raijinLabsLucidAi, {
body: {
model: "mistral-7b-instruct",
messages: [
{
role: "system",
content: "You are a helpful AI assistant.",
},
{
role: "user",
content: "Explain how MMR proofs work in one paragraph.",
},
],
maxTokens: 256,
temperature: 0.7,
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("runChatCompletions failed:", res.error);
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|
request | operations.LucidChatCompletionsRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<models.ChatCompletionResponse>
Errors
| Error Type | Status Code | Content Type |
|---|
| errors.ErrorResponse | 400 | application/json |
| errors.X402PaymentRequiredError | 402 | application/json |
| errors.ErrorResponse | 500 | application/json |
| errors.RaijinLabsLucidAiDefaultError | 4XX, 5XX | */* |