inferlane-exchange
v0.0.5
Published
Official TypeScript SDK for the InferLane Exchange — verified AI inference marketplace with consensus, audits, and per-call settlements.
Maintainers
Readme
inferlane-exchange
Official TypeScript SDK for the InferLane Exchange — a verified AI inference marketplace with consensus, audits, and per-call settlements.
Install
npm install inferlane-exchangeQuickstart
import { ExchangeClient } from 'inferlane-exchange';
const client = new ExchangeClient({
baseUrl: 'https://app.inferlane.com',
apiKey: process.env.INFERLANE_API_KEY!, // starts with `il_`
});
// As a buyer: check wallet balance
const wallet = await client.wallet.get();
console.log(`Balance: $${(Number(wallet.balanceUsdCents) / 100).toFixed(2)}`);
// As a buyer: run a classification with verified consensus across 3 providers
const result = await client.compute.invokeReplicated({
taskType: 'classification',
input: 'Schedule a meeting with Sarah tomorrow at 2pm.',
outputSchema: { label: 'string', confidence: 'number' },
replicationFactor: 3,
});
console.log('consensus:', result.consensusOutput);
console.log('judge:', result.judge?.rationale);
console.log('cost:', result.receipt?.totalChargedUsdCents);
// As an operator: discover and apply to tasks
const tasks = await client.tasks.listOpen({ category: 'code-review' });
await client.tasks.apply(tasks.tasks[0].id, {
estimatedHours: 2,
estimatedCostUsd: 80,
});What it covers
| Surface | Methods |
|---------|---------|
| client.wallet | get, topup |
| client.providers | list, get, register, deregister |
| client.compute | invoke, invokeReplicated |
| client.tasks | listOpen, get, post, fund, approve, reject, apply, submit, listMine |
| client.disputes | list, addEvidence, withdraw |
| client.notifications | list, markAllRead |
| client.webhooks | listSubscriptions, createSubscription, deleteSubscription |
| client.admin.providers | listApplications, admit, decline, recordCalibration, promoteToAnchor, writeoffAccrual |
Auth
Get an API key from /dashboard/settings/api-keys after signing in. Keys start with il_. The SDK validates the prefix at construction time so you can't accidentally pass a SHA-256 hash instead of the raw token.
Error handling
import { ExchangeError } from 'inferlane-exchange';
try {
await client.compute.invoke({ taskType: 'classification', input: '...', outputSchema: {} });
} catch (e) {
if (e instanceof ExchangeError) {
console.error(`HTTP ${e.status}: ${e.code} — ${e.message}`);
// e.body contains the server response JSON if available
}
}Custom fetch / timeouts
Per-request timeout defaults to 30s. Override via constructor or per-request:
const client = new ExchangeClient({
baseUrl,
apiKey,
timeoutMs: 60_000, // global default
fetch: customFetchImpl, // e.g. for Node 16 polyfill
});
// Per-request override via the low-level http surface:
await client.http.request('POST', '/api/exchange/compute/invoke', {
body: { /* ... */ },
timeoutMs: 5_000,
});Status
Early access. The 8 client surfaces above cover the buyer + operator + admin v1 flows. Compute substrate (single-mode + replicated) is production-ready; third-party provider settlements (STRIPE_BOND_ESCROW_WIRED) are gated until the Exchange operator flips the production gate.
License
MIT
