{"_id":"@alveare-ai/sdk","name":"@alveare-ai/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alveare-ai/sdk","version":"0.1.0","description":"Official TypeScript SDK for the Alveare Private SLM Inference-as-a-Service platform","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build","typecheck":"tsc --noEmit"},"keywords":["alveare","inference","slm","ai","machine-learning","sdk"],"license":"MIT","engines":{"node":">=18.0.0"},"devDependencies":{"@types/node":"^25.5.0","typescript":"^5.4.0"},"_id":"@alveare-ai/sdk@0.1.0","gitHead":"6747d650207af2f46dc73d98f7dfa6b443b9901e","_nodeVersion":"20.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-4qL3GyswN5aB/kq6rgAX8L4IexWzCButIbgasMWd2JuZga05IFwwIKkhhM5frfJiMNMYDK2wvoz3u6y1rANbtg==","shasum":"afc6a4fa56aad4ce1469dbc5ab6777c939943164","tarball":"https://registry.npmjs.org/@alveare-ai/sdk/-/sdk-0.1.0.tgz","fileCount":18,"unpackedSize":42911,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDTV4IS9VlrlWy26LN32RrHnB93ZgBTEoatH0FwnFW50QIhAMBl9BpP21JSElRf9GmHqL3htWxMW6gwTyKsGjQmKYTp"}]},"_npmUser":{"name":"alveare","email":"npm@alveare.ai"},"directories":{},"maintainers":[{"name":"alveare","email":"npm@alveare.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1773735119690_0.9307675268094724"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-17T08:11:59.587Z","0.1.0":"2026-03-17T08:11:59.836Z","modified":"2026-03-17T08:12:00.086Z"},"maintainers":[{"name":"alveare","email":"npm@alveare.ai"}],"description":"Official TypeScript SDK for the Alveare Private SLM Inference-as-a-Service platform","keywords":["alveare","inference","slm","ai","machine-learning","sdk"],"license":"MIT","readme":"# @alveare/sdk\n\nOfficial TypeScript SDK for the **Alveare** Private SLM Inference-as-a-Service platform.\n\n## Installation\n\n```bash\nnpm install @alveare/sdk\n```\n\nRequires **Node.js 18+** (uses native `fetch`). Zero runtime dependencies.\n\n## Quick start\n\n```typescript\nimport Alveare from '@alveare/sdk';\n\nconst client = new Alveare({ apiKey: 'alv_live_...' });\n\n// Native inference\nconst result = await client.infer({\n  specialist: 'summarise',\n  prompt: 'Summarise this quarterly report...',\n  maxTokens: 256,\n});\nconsole.log(result.text);\n```\n\n## Authentication\n\nPass your API key directly or set the `ALVEARE_API_KEY` environment variable:\n\n```bash\nexport ALVEARE_API_KEY=alv_live_abcdef0123456789abcdef0123456789\n```\n\n```typescript\nconst client = new Alveare(); // reads from env\n```\n\nProduction keys start with `alv_live_`, sandbox keys with `alv_test_`.\n\n## Usage\n\n### Native inference\n\n```typescript\nconst result = await client.infer({\n  specialist: 'summarise',\n  prompt: 'Summarise this quarterly report...',\n  maxTokens: 256,\n});\n\nconsole.log(result.text);       // generated text\nconsole.log(result.tokensUsed); // token count\nconsole.log(result.latencyMs);  // server latency\nconsole.log(result.cached);     // whether result was cached\n```\n\n### Chat completions (OpenAI-compatible)\n\n```typescript\nconst completion = await client.chat.completions.create({\n  model: 'alveare-summarise',\n  messages: [{ role: 'user', content: 'Summarise this...' }],\n  maxTokens: 256,\n});\n\nconsole.log(completion.choices[0].message.content);\n```\n\n### Usage stats\n\n```typescript\nconst usage = await client.usage();\n```\n\n### List models\n\n```typescript\nconst models = await client.models.list();\nfor (const m of models.data) {\n  console.log(m.id);\n}\n```\n\n### Health check\n\n```typescript\nconst health = await client.health();\n```\n\n## Configuration\n\n```typescript\nconst client = new Alveare({\n  apiKey: 'alv_live_...',           // or ALVEARE_API_KEY env var\n  baseUrl: 'https://custom.host',   // or ALVEARE_BASE_URL env var\n  maxRetries: 3,                    // automatic retries (default: 3)\n  timeout: 30_000,                  // request timeout in ms (default: 30 000)\n});\n```\n\n## Error handling\n\n```typescript\nimport Alveare, {\n  AlveareError,\n  AuthenticationError,\n  RateLimitError,\n  APIError,\n} from '@alveare/sdk';\n\ntry {\n  await client.infer({ specialist: 'summarise', prompt: '...' });\n} catch (err) {\n  if (err instanceof AuthenticationError) {\n    // Invalid or missing API key (401/403)\n  } else if (err instanceof RateLimitError) {\n    // Rate limited (429) — err.retryAfter may contain seconds to wait\n  } else if (err instanceof APIError) {\n    // Other HTTP error — err.status, err.body\n  } else if (err instanceof AlveareError) {\n    // Base SDK error (timeout, network, config)\n  }\n}\n```\n\n## Automatic retries\n\nThe SDK retries automatically on:\n\n- **429** Too Many Requests (respects `Retry-After` header)\n- **408** Request Timeout\n- **5xx** Server errors\n\nRetries use exponential backoff with jitter. Configure via `maxRetries` (default: 3).\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-ee85f6ec811ad0723e7afe99623ffbb9"}