SDKs
TypeScript SDK
lexicor-client is the official TypeScript/JavaScript client for the Lexicor HTTP API, built on fetch. It ships typed request and response models for every endpoint.
Install
bash
npm install lexicor-clientQuick start
Quick start
import { LexicorClient } from "lexicor-client";
const client = new LexicorClient({
baseUrl: "https://api.lexicor.dev",
apiKey: "lx-your-key",
});
const normalized = await client.normalize(myGraph);
const result = await client.roundtrip(myGraph);Ingress with LM fallback
Ingress
await client.ingest("Some unusual directive…", {
lmFallback: true,
buildPacket: true,
renderStrategy: "ascii_compact",
});Negotiation and full packets
Negotiation and packets
const agentId = "my-remote-agent";
await client.negotiateAdvertise(agentId, {
supportedCodecs: ["lexicor-line-v1"],
supportedSymbolTables: ["core-sym-1"],
supportedFidelityTiers: [0, 1, 2, 3],
});
const offer = await client.negotiateOffer("sess-001", agentId);
if (offer.type !== "offer") throw new Error(offer.reason ?? "negotiation failed");
const contract = offer.contract!;
await client.negotiateConfirm("sess-001");
contract.session_id = "sess-001";
const { packet } = await client.packetBuild(intentGraph, {
session: contract,
renderStrategy: "ascii_compact",
payloadMode: "semantic_transport",
});
const { intent_graph } = await client.packetDecode(packet);Strict decode
packetDecode(packet, { strict: true }) raises a PayloadModeError when a packet’s payload mode is lossy, and sends X-Lexicor-Strict-Mode: 1 for server-side enforcement.
Features
- Typed request/response models for every endpoint.
- Automatic retry with exponential backoff.
- Rate-limit handling (429 with
Retry-After).
Endpoint-level detail lives in the API reference.