Skip to main content

Installation

npm install raijin-labs-lucid-ai

Quick Start

import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const sdk = new RaijinLabsLucidAi({
  serverURL: "https://api.lucid.foundation",
});

// Check system health
const health = await sdk.health.checkSystemHealth();
console.log("Status:", health.status);

SDK Namespaces

The SDK is organized into namespaces matching the API groups:
NamespaceDescriptionMethods
sdk.passportsIdentity passports (model, compute, tool, dataset, agent)1
sdk.matchModel matching and routing1
sdk.runInference execution1
sdk.receiptsCryptographic receipts and verification1
sdk.epochsEpoch management and anchoring1
sdk.payoutsPayout calculations1
sdk.agentsAI Agent orchestration1
sdk.computeCompute node management1
sdk.healthSystem health checks1

Authentication

import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const sdk = new RaijinLabsLucidAi({
  serverURL: "https://api.lucid.foundation",
  // API key authentication (when required)
  // security: { bearerAuth: "YOUR_API_KEY" }
});

Passport CRUD Example

import { RaijinLabsLucidAi } from "raijin-labs-lucid-ai";

const sdk = new RaijinLabsLucidAi({
  serverURL: "https://api.lucid.foundation",
});

const OWNER = "YOUR_WALLET_ADDRESS";

// Create a model passport
const model = await sdk.passports.create({
  type: "model",
  owner: OWNER,
  name: "my-llm-7b",
  description: "7B parameter language model",
  version: "1.0.0",
  tags: ["nlp", "inference"],
  metadata: {
    schema_version: "1.0",
    model_passport_id: "mdl-my-llm-7b",
    format: "gguf",
    runtime_recommended: "vllm",
    name: "my-llm-7b",
    context_length: 4096,
    requirements: { min_vram_gb: 24 },
  },
});
console.log("Model passport:", model.passportId);

// Create a compute passport
const compute = await sdk.passports.create({
  type: "compute",
  owner: OWNER,
  name: "gpu-node-us-east",
  version: "1.0.0",
  tags: ["gpu", "a100"],
  metadata: {
    schema_version: "1.0",
    compute_passport_id: "cmp-gpu-node-us-east",
    provider_type: "cloud",
    regions: ["us-east-1"],
    hardware: { gpu: "NVIDIA-A100-80GB", vram_gb: 80 },
    runtimes: [{ name: "vllm", version: "0.4.0", image: "vllm/vllm:0.4.0" }],
    endpoints: { inference_url: "http://my-node:8080/v1" },
  },
});
console.log("Compute passport:", compute.passportId);

// List passports
const list = await sdk.passports.list({ owner: OWNER, perPage: 10 });
console.log("Total:", list.pagination.total);

// Update a passport
await sdk.passports.update({
  passportId: model.passportId,
  xOwnerAddress: OWNER,
  body: { description: "Updated description", version: "1.0.1" },
});

// Delete a passport (soft delete)
await sdk.passports.delete({
  passportId: model.passportId,
  xOwnerAddress: OWNER,
});

Standalone Functions (Tree-Shaking)

For browser and serverless environments, every method is available as a standalone function for optimal tree-shaking:
import { RaijinLabsLucidAiCore } from "raijin-labs-lucid-ai/core.js";
import { passportsCreate } from "raijin-labs-lucid-ai/funcs/passportsCreate.js";

const client = new RaijinLabsLucidAiCore();

const res = await passportsCreate(client, {
  type: "model",
  owner: "YOUR_WALLET",
  metadata: { schema_version: "1.0", name: "my-model" },
});

if (res.ok) {
  console.log(res.value);
}

Error Handling

import { SDKValidationError } from "raijin-labs-lucid-ai/models/errors";

try {
  const result = await sdk.passports.create({ /* ... */ });
} catch (err) {
  if (err instanceof SDKValidationError) {
    console.error("Validation error:", err.message);
  }
  throw err;
}

Supported Runtimes

  • Node.js >= 18
  • Deno
  • Bun
  • Cloudflare Workers
  • Edge runtimes (Vercel Edge, etc.)