Quickstart

Get from zero to a validated AIPC contract in under five minutes.

1. Install the runtime

The AIPC runtime is published as an npm package. Install it alongside your project:

npm install @aipc/runtime

2. Write a minimal contract

An AIPC response wraps your data payload with a contract envelope. Here is the simplest possible example — a weather data provider that requires attribution:

{
  "aipc_version": "0.1.0",
  "provider": {
    "id": "weather-co",
    "name": "WeatherCo",
    "contract_version": "1.0.0"
  },
  "contract": {
    "disclosures": [
      {
        "id": "data-source",
        "text": "Weather data provided by WeatherCo.",
        "verbatim": true,
        "scope": ["*"],
        "placement": "global",
        "priority": "required"
      }
    ],
    "display_rules": [
      {
        "scope": ["temperature"],
        "label": { "text": "Temperature", "verbatim": false },
        "format": { "type": "number", "precision": 1, "unit": "°F" }
      }
    ],
    "attribution": {
      "required": true,
      "text": "Data provided by WeatherCo",
      "verbatim": true,
      "placement": "global"
    },
    "freshness": {
      "generated_at": "2026-02-16T12:00:00Z",
      "valid_until": "2026-02-16T13:00:00Z",
      "stale_behavior": "warn",
      "expired_behavior": "suppress"
    },
    "fail_behavior": "suppress"
  },
  "payload": {
    "city": "San Francisco",
    "temperature": 62.3,
    "conditions": "Partly cloudy"
  }
}

3. Validate the response

Import the runtime and pass the response through validation. Three lines of code:

import { AIPCRuntime } from '@aipc/runtime';

const runtime = new AIPCRuntime();
const result = runtime.validate(response);

4. Inspect the output

The result object contains everything an AI agent needs to present the data correctly:

{
  "success": true,
  "compliance_level": "L2",
  "formatted_fields": [
    { "label": "Temperature", "formatted_value": "62.3°F" }
  ],
  "disclosures": {
    "global": ["Weather data provided by WeatherCo."]
  },
  "attribution": "Data provided by WeatherCo",
  "freshness_status": "valid"
}

5. Generate prompt instructions

Feed the validated output into the prompt builder to produce instructions that any LLM can follow:

import { AIPCPromptBuilder } from '@aipc/runtime';

const instructions = AIPCPromptBuilder.buildPromptInstructions(result);
console.log(instructions);

This outputs a structured markdown block that tells the model exactly what to include, what to avoid, and what to do if it cannot comply.

6. Render deterministic blocks (L2+)

For L2+ enforcement, render compliance-critical elements with deterministic code instead of relying on the LLM:

import { AIPCRenderer } from '@aipc/runtime';

const renderer = new AIPCRenderer();
const rendered = renderer.render(result, { modality: 'visual', visualFormat: 'html' });

// rendered.blocks — disclosures, data, attribution rendered by code
// rendered.narrativeContext — context for LLM to generate narrative

The LLM generates only the narrative text. Disclosures, data formatting, and attribution are handled by code and cannot be modified by the AI.

7. Validate and assemble (L3)

For full L3 enforcement, use the Compositor to validate LLM narrative and assemble the final response:

import { AIPCCompositor } from '@aipc/runtime';

const response = await AIPCCompositor.enforce({
  validatedOutput: result,
  narrativeText: llmGeneratedText,
  retryCallback: async (prompt) => callLLM(prompt),
});

if (response.success) {
  // response.assembled.html — ready to display
  // response.audit — full compliance trail
}

Next steps