{"_id":"@arcrouter/sdk","_rev":"2-eff18762295dceb2f71f88932d5b193e","name":"@arcrouter/sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@arcrouter/sdk","version":"0.1.0","keywords":["arcrouter","llm","routing","ai","openai","council","consensus","x402"],"author":{"name":"ArcRouter"},"license":"MIT","_id":"@arcrouter/sdk@0.1.0","maintainers":[{"name":"jxnis94","email":"janis.ellerbrock+1@gmail.com"}],"homepage":"https://arcrouter.com","bugs":{"url":"https://github.com/ArcRouterAI/arcrouter-sdk/issues"},"dist":{"shasum":"cb974d0c0c947906d45d2727ffa407bd218f909a","tarball":"https://registry.npmjs.org/@arcrouter/sdk/-/sdk-0.1.0.tgz","fileCount":7,"integrity":"sha512-N4y3v7ir8BC7T8M2EuHKU4EAP+zAYZIjVfB4nADOMoOCoBMpPkIPo5910SK0e9ZE7VnSS4J1MgOH92u4+N/9Xg==","signatures":[{"sig":"MEQCIFQR74NuoF9zpHgG2AcyFRSCv7Pkoj8cJYS9oMMNN0gEAiB4AaJQ64z450igDTIfhIQj8EdFdJkfM9HS3ZTEQVlVug==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51756},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"7fc1f2d5a240f15968bc646ef5a2859fb250da71","scripts":{"dev":"tsup src/index.ts --format cjs,esm --watch --dts","lint":"tsc","build":"tsup src/index.ts --format cjs,esm --dts"},"_npmUser":{"name":"jxnis94","email":"janis.ellerbrock+1@gmail.com"},"repository":{"url":"git+https://github.com/ArcRouterAI/arcrouter-sdk.git","type":"git"},"_npmVersion":"10.9.0","description":"Official TypeScript SDK for ArcRouter — intelligent LLM routing with multi-model consensus","directories":{},"_nodeVersion":"22.12.0","dependencies":{"openai":"^4.76.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","typescript":"^5.7.2","@types/node":"^22.10.2"},"peerDependencies":{"viem":">=2.0.0","@x402/evm":">=2.0.0","@x402/core":">=2.0.0"},"peerDependenciesMeta":{"viem":{"optional":true},"@x402/evm":{"optional":true},"@x402/core":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1775923982201_0.4321417817184172","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@arcrouter/sdk","version":"0.1.1","type":"module","description":"Official TypeScript SDK for ArcRouter — intelligent LLM routing with multi-model consensus","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts","dev":"tsup src/index.ts --format cjs,esm --watch --dts","lint":"tsc"},"keywords":["arcrouter","llm","routing","ai","openai","council","consensus","x402"],"author":{"name":"ArcRouter"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ArcRouterAI/arcrouter-sdk.git"},"homepage":"https://arcrouter.com","dependencies":{"openai":"^4.76.0"},"devDependencies":{"@types/node":"^22.10.2","tsup":"^8.3.5","typescript":"^5.7.2"},"peerDependencies":{"viem":">=2.0.0","@x402/core":">=2.0.0","@x402/evm":">=2.0.0"},"peerDependenciesMeta":{"viem":{"optional":true},"@x402/core":{"optional":true},"@x402/evm":{"optional":true}},"_id":"@arcrouter/sdk@0.1.1","gitHead":"84fdc087cda8e51c2b2efce5fec780b090888ab0","bugs":{"url":"https://github.com/ArcRouterAI/arcrouter-sdk/issues"},"_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-hFvRn68AM6ee40MEM5DeAndd50/LX0aP1bVhAAquk2j1V2Vc5Oix6gozXhoBkSqzHD0xSjErhFkp4QEF9id3ZQ==","shasum":"929a0c0592d5f7bca42000ed2948eb99626e1655","tarball":"https://registry.npmjs.org/@arcrouter/sdk/-/sdk-0.1.1.tgz","fileCount":7,"unpackedSize":52080,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCMy4mw3e5FouHNnE0waqjVrz7jvIsPILAe+YsHLtkI5AIhALSBfnypeIrbW1TE+M8xmscwTsH1P11KIhTte59QObes"}]},"_npmUser":{"name":"jxnis94","email":"janis.ellerbrock+1@gmail.com"},"directories":{},"maintainers":[{"name":"jxnis94","email":"janis.ellerbrock+1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.1_1775929934532_0.25460138732092763"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-11T16:13:02.126Z","modified":"2026-04-11T17:52:14.776Z","0.1.0":"2026-04-11T16:13:02.324Z","0.1.1":"2026-04-11T17:52:14.645Z"},"bugs":{"url":"https://github.com/ArcRouterAI/arcrouter-sdk/issues"},"author":{"name":"ArcRouter"},"license":"MIT","homepage":"https://arcrouter.com","keywords":["arcrouter","llm","routing","ai","openai","council","consensus","x402"],"repository":{"type":"git","url":"git+https://github.com/ArcRouterAI/arcrouter-sdk.git"},"description":"Official TypeScript SDK for ArcRouter — intelligent LLM routing with multi-model consensus","maintainers":[{"name":"jxnis94","email":"janis.ellerbrock+1@gmail.com"}],"readme":"# @arcrouter/sdk\n\nOfficial TypeScript SDK for [ArcRouter](https://arcrouter.com) — intelligent LLM routing with multi-model consensus.\n\n## Installation\n\n```bash\nnpm install @arcrouter/sdk\n```\n\n## Quick Start\n\n```typescript\nimport { ArcRouter } from '@arcrouter/sdk';\n\nconst arc = new ArcRouter({ apiKey: 'sk_...' });\n\n// Smart routing — picks the best model for your prompt\nconst res = await arc.chat('Write a Python function to merge two sorted lists');\nconsole.log(res.content);\nconsole.log(res.routing.model);           // e.g. \"anthropic/claude-sonnet-4-5\"\nconsole.log(res.routing.estimatedCostUsd); // e.g. 0.0012\n```\n\n## Features\n\n- **Smart Routing** — routes each prompt to the best model by topic, complexity, and budget\n- **Council Mode** — multi-model consensus for higher confidence answers\n- **Streaming** — async generator for real-time text output\n- **Workflow Budgets** — cap spend across multi-step agent workflows\n- **x402 Micropayments** — automatic USDC payments on Base (no API key needed)\n- **Auto Retry** — exponential backoff on 5xx errors\n- **OpenAI Drop-In** — `arc.openai()` returns a standard OpenAI client pointed at ArcRouter\n- **Full TypeScript** — complete types for all responses and options\n\n## API\n\n### `arc.chat(prompt, options?)`\n\nRoute to the best single model. Fast, cheap, smart.\n\n```typescript\nconst res = await arc.chat('Explain quantum entanglement', {\n  budget: 'premium',           // 'free' | 'economy' | 'auto' | 'premium'\n  agentStep: 'reasoning',      // hints complexity to the router\n  maxCost: 0.01,               // USD cap per request\n  excludeModels: ['deepseek/deepseek-r1'],\n  sessionId: 'session-123',    // model pinning across turns\n});\n\nconsole.log(res.content);       // The answer\nconsole.log(res.routing.model); // Which model was chosen\nconsole.log(res.routing.topic); // Detected topic (e.g. \"science/physics\")\n```\n\n### `arc.council(prompt, options?)`\n\nMulti-model consensus. 3-7 models vote, majority wins.\n\n```typescript\nconst res = await arc.council('Is P = NP?');\nconsole.log(res.content);      // Consensus answer\nconsole.log(res.confidence);   // 0-1\nconsole.log(res.votes);        // Individual model answers\nconsole.log(res.synthesized);  // true if chairman had to resolve disagreement\n```\n\n### `arc.stream(prompt, options?)`\n\nAsync generator for streaming responses.\n\n```typescript\nfor await (const chunk of arc.stream('Write a story about...')) {\n  process.stdout.write(chunk);\n}\n```\n\n### `arc.models(options?)`\n\nList available models with benchmark scores and pricing.\n\n```typescript\nconst models = await arc.models({ topic: 'code', budget: 'auto' });\nmodels.forEach(m => console.log(`${m.name}: $${m.inputPricePer1M}/1M tokens`));\n```\n\n### `arc.usage(options?)`\n\nGet your API key's usage history.\n\n```typescript\nconst stats = await arc.usage({ days: 30 });\nconsole.log(`${stats.totalRequests} requests, $${stats.totalCostUsd} total`);\n```\n\n### `arc.workflow(options)`\n\nCreate a multi-step workflow with shared budget tracking.\n\n```typescript\nconst wf = arc.workflow({\n  sessionId: 'agent-run-42',\n  totalBudget: 5.00,  // USD\n});\n\nconst plan = await wf.chat('Plan the implementation', { agentStep: 'planning' });\nconst code = await wf.chat('Write the code', { agentStep: 'code-generation' });\nconst review = await wf.chat('Review for bugs', { agentStep: 'verification' });\n\nconst usage = await wf.getUsage();\nconsole.log(`Spent $${usage.total_spent_usd} of $${usage.total_budget_usd}`);\n```\n\n### `arc.openai()`\n\nDrop-in OpenAI client — zero-code migration.\n\n```typescript\nconst client = arc.openai();\nconst completion = await client.chat.completions.create({\n  model: 'gpt',  // alias — ArcRouter resolves to best GPT model\n  messages: [{ role: 'user', content: 'Hello' }],\n});\n```\n\n## Agent Step Headers\n\nWhen building agent frameworks, use `agentStep` to tell the router what kind of work each step does:\n\n| Step | Maps to | Use for |\n|------|---------|---------|\n| `simple-action` | SIMPLE | Formatting, extraction, simple lookups |\n| `code-generation` | COMPLEX + code topic | Writing code |\n| `reasoning` | REASONING | Analysis, planning, complex decisions |\n| `verification` | Council mode | Cross-checking, validation |\n\n### x402 Micropayments\n\nPay per request with USDC on Base — no API key needed. The SDK automatically handles 402 responses, signs an on-chain payment authorization, and retries.\n\n```bash\nnpm install @arcrouter/sdk viem @x402/core @x402/evm\n```\n\n```typescript\nimport { ArcRouter } from '@arcrouter/sdk';\nimport { privateKeyToAccount } from 'viem/accounts';\n\nconst arc = new ArcRouter({\n  wallet: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`),\n  budget: 'auto', // x402 pricing: $0.001 simple, $0.002 medium, $0.005 complex\n});\n\nconst res = await arc.chat('Explain quantum computing');\n// Payment signed and sent automatically — no API key required\n```\n\nPricing varies by prompt complexity:\n| Complexity | Price |\n|-----------|-------|\n| SIMPLE | $0.001 |\n| MEDIUM | $0.002 |\n| COMPLEX | $0.005 |\n| REASONING | $0.008 |\n\n### Auto Retry\n\nThe SDK automatically retries on 5xx errors with exponential backoff (default: 2 retries).\n\n```typescript\nconst arc = new ArcRouter({\n  apiKey: 'sk_...',\n  maxRetries: 3, // default: 2\n});\n```\n\n## License\n\nMIT\n\n## Links\n\n- **Docs:** https://arcrouter.com/docs\n- **API:** https://api.arcrouter.com\n- **GitHub:** https://github.com/ArcRouterAI/arcrouter-sdk\n","readmeFilename":"README.md"}