nexart.iodocs

    LangChain Integration

    Integrate NexArt with LangChain agents so every agent run produces a Certified Execution Record: callback wiring, snapshot fields and hash verification.

    Only use this page if you're integrating with LangChain

    The createLangChainCer / certifyLangChainRun helpers documented here are thin DTO adapters in @nexart/ai-execution/langchain for inputs already shaped as a LangChain Run or callback payload.

    For OpenAI SDK, Anthropic SDK, raw HTTP, n8n, custom code, or any other framework, use the framework-agnostic primitives certifyDecision and certifyAndAttestDecision from @nexart/ai-execution instead. See the AI Execution SDK page.

    Best For

    • AI agents that make decisions requiring audit trails
    • LangChain chains and multi-step workflows
    • Decision systems (moderation, policy review, approvals)
    • Application logic that needs verifiable execution records

    Overview

    LangChain workflows can produce Certified Execution Records (CERs) using the NexArt AI Execution SDK. A CER is a cryptographically bound record of an AI execution, including inputs, outputs, and execution metadata. The record produces a deterministic certificate hash and can optionally be attested by a NexArt node.

    LangChain workflow
    ↓
    createLangChainCer()
    ↓
    CER bundle + certificate hash
    ↓ (optional)
    NexArt node attestation
    ↓
    verify.nexart.io

    Two Integration Paths

    The SDK provides two helpers depending on whether you need node attestation:

    • createLangChainCer(...) creates a CER locally. No network call. Returns a deterministic certificate hash you can verify independently.
    • certifyLangChainRun(...) creates a CER and sends it to a NexArt node for attestation. Returns a signed receipt and a public verification URL.

    V2: createLangChainCerV2 (recommended)

    createLangChainCerV2 is a root export of @nexart/ai-execution (not a /langchain subpath import) and produces a cer.ai.execution.v2 record. See AI Execution V2 for the full snapshot schema and Migration: V1 to V2 for upgrading an existing V1 LangChain integration.

    LangChainCertificationInputV2

    • Required: provider, model, input, output, executionRole ('advisory' | 'operative' | 'unspecified', producer-declared, never inferred by NexArt).
    • Optional: instruction, which REQUIRES a paired instructionKind ('system' | 'derived' | 'label') whenever present, and FORBIDS instructionKind when instruction is absent.
    • Optional: modelEvidence - producer-transcribed evidence about the model response (for example responseDeclaredModel). This is never provider-signed proof and must never overwrite the required, producer-declared model field.
    • Optional: toolCalls - sealed alongside the snapshot.
    • Optional: parameters - execution parameters (temperature, maxTokens, etc.).
    • Optional: confidential sealing options, for producing a cer.ai.execution.v2 bundle with committed fields instead of plaintext. See Confidential Mode.
    Local V2 CER creation
    import { createLangChainCerV2 } from "@nexart/ai-execution";
    
    const result = createLangChainCerV2({
      provider: "openai",
      model: "gpt-4o-mini",
      input: {
        messages: [
          { role: "user", content: "Should this customer refund request be escalated?" }
        ]
      },
      output: {
        decision: "escalate",
        reason: "high_value_customer"
      },
      executionRole: "advisory",
      instruction: "Decide whether to escalate this refund request.",
      instructionKind: "derived",
    });
    
    const { bundle, certificateHash } = result; // LangChainCerV2Result
    console.log(certificateHash);

    LangChainCerV2Result

    Contains the sealed cer.ai.execution.v2 bundle and its certificateHash. Use verifyCerV2 / verifyCerV2Async from @nexart/ai-execution to verify it, and attest(bundle, options) to submit it to a NexArt node for attestation. See the AI Execution SDK page for the full verification and attestation reference.

    V1: createLangChainCer / certifyLangChainRun (supported)

    The V1 subpath helpers below remain fully supported for teams already on cer.ai.execution.v1.

    Installation

    npm install @nexart/ai-execution

    The LangChain integration is available as a subpath import:

    import { createLangChainCer } from "@nexart/ai-execution/langchain";

    Create a CER Locally

    Generate a CER from a LangChain run without contacting the node. This creates a Certified Execution Record locally and returns a deterministic certificate hash.

    Local CER Creation
    import { createLangChainCer } from "@nexart/ai-execution";
    
    const { bundle, certificateHash } = createLangChainCer({
      provider: "openai",
      model: "gpt-4o-mini",
      input: {
        messages: [
          { role: "user", content: "Should this customer refund request be escalated?" }
        ]
      },
      output: {
        decision: "escalate",
        reason: "high_value_customer"
      }
    });
    
    console.log(certificateHash);

    Certify with the NexArt Node

    When a node URL is provided, the record is attested by the NexArt node and includes a signed receipt. This step is optional. Local CER creation is sufficient for many use cases.

    Node Attestation
    import { certifyLangChainRun } from "@nexart/ai-execution";
    
    const result = await certifyLangChainRun({
      provider: "openai",
      model: "gpt-4o-mini",
      input: {
        messages: [
          { role: "user", content: "Should this customer refund request be escalated?" }
        ]
      },
      output: {
        decision: "escalate",
        reason: "high_value_customer"
      },
      nodeUrl: "https://your-nexart-node.example",
      apiKey: process.env.NEXART_API_KEY
    });
    
    console.log(result.verificationUrl);

    Verification

    A CER produced by LangChain can be verified the same way as any other NexArt record. Open https://verify.nexart.io and verify using:

    • Execution ID: look up by the execution identifier
    • Certificate hash: paste the deterministic hash
    • Uploaded CER bundle: upload the full bundle for offline-first verification

    Use Cases

    • AI agent decisions that require audit trails
    • Moderation pipelines with verifiable outputs
    • Workflow approvals backed by tamper-evident records
    • AI-assisted automation with certification

    Official Example Repo

    github.com/artnames/nexart-langchain - runnable integration example for LangChain chains and agent workflows.

    Next Steps

    • Quickstart: create your first CER in three steps
    • Verification: deep dive into verification semantics
    • Examples: copy-ready API requests and response shapes