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
Initialize the SDK
import { LucidAI } from "raijin-labs-lucid-ai";
const lucid = new LucidAI({
bearerAuth: process.env.LUCID_API_KEY,
});
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);
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);
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
- Your request was matched to the best available model
- The LLM processed your request
- A cryptographic receipt was generated with SHA-256 hashes of input/output
- The receipt was signed by the session signer (Ed25519)
- The receipt was added to the current epoch’s MMR
- The epoch will be anchored on Solana when it closes
Next Steps