ยง 04 ยท Developer API & SDK
Install. Configure. Ship.
One import replaces your OpenAI client. The SDK negotiates with the mesh on the first request and routes automatically from there.
4.1
Install
bash
# Browser / Node
npm install @meshinfer.ai/sdk
# React bindings
npm install @meshinfer.ai/react
# Python
pip install meshinfer.ai
# Desktop (auto-updates after install)
curl -fsSL https://meshinfer.ai/install.sh | sh4.2
Quickstart
javascript
import { MeshInfer } from '@meshinfer.ai/sdk';
const mesh = new MeshInfer({ apiKey: 'msk_live_...' });
const res = await mesh.chat({
model: 'local-small',
messages: [{ role: 'user', content: 'Hello' }],
latency_preference: 'low',
cost_preference: 'cheap',
});
console.log(res.choices[0].message.content);
console.log('routed via:', res.route); // 'local' | 'mesh' | 'cloud'
console.log('cost saved:', res.savings_usd);4.3
REST reference
Endpoints
Request parameters โ /v1/ai/chat
4.4
Model catalog
4.5
Error codes
4.6
SDK init options
typescript
new MeshInfer({
apiKey: string,
mode?: 'auto' | 'local-only' | 'cloud-only' | 'mesh', // default 'auto'
maxLocalRamMb?: number, // default 40% of ram_free
allowMeshParticipation?: boolean,// default true โ user contributes back
consent?: 'explicit' | 'implicit',// default 'explicit' (GDPR)
telemetry?: boolean, // default true, anonymous perf only
endpoint?: string, // override (for on-prem coordinator)
});OpenAI drop-in
The SDK exposes an
openai-compatible surface. Swap new OpenAI() for new MeshInfer.AI() and ship.