Skip to main content
This guide walks you through running an AI inference and verifying the cryptographic receipt.

Prerequisites

  • A Lucid API key (get one here)
  • Node.js 18+ installed
  • raijin-labs-lucid-ai SDK installed

Steps

1

Initialize the SDK

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

const lucid = new LucidAI({
  bearerAuth: process.env.LUCID_API_KEY,
});
2

Send a chat completion

const response = await lucid.chat.completions({
  model: "gpt-4o",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "What is verifiable AI inference?" }
  ],
  temperature: 0.7,
});

console.log(response.choices[0].message.content);
3

Get the receipt

// The receipt ID is returned in the response
const receiptId = response.receiptId;
const receipt = await lucid.receipts.get(receiptId);

console.log("Receipt ID:", receipt.id);
console.log("Input hash:", receipt.inputHash);
console.log("Output hash:", receipt.outputHash);
console.log("Epoch:", receipt.epochId);
4

Verify the receipt

const verification = await lucid.receipts.verify(receiptId);

console.log("Signature valid:", verification.signatureValid);
console.log("MMR proof valid:", verification.proofValid);
console.log("Overall valid:", verification.valid);
The receipt is created automatically — no extra API call needed during inference.

What Happened

  1. Your request was matched to the best available model
  2. The LLM processed your request
  3. A cryptographic receipt was generated with SHA-256 hashes of input/output
  4. The receipt was signed by the session signer (Ed25519)
  5. The receipt was added to the current epoch’s MMR
  6. The epoch will be anchored on Solana when it closes

Next Steps