{"_id":"@agentrouter-top/sdk","name":"@agentrouter-top/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agentrouter-top/sdk","version":"0.1.0","description":"Official server-side TypeScript SDK for AgentRouter management and analytics APIs.","license":"MIT","type":"module","sideEffects":false,"engines":{"node":">=20.18"},"exports":{".":{"types":"./dist/esm/index.d.ts","browser":"./dist/esm/browser.js","import":"./dist/esm/index.js","require":"./dist/cjs/index.js","default":"./dist/esm/index.js"}},"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/esm/index.d.ts","publishConfig":{"access":"public","provenance":true},"repository":{"type":"git","url":"git+https://github.com/Maybank01/agentrouter-cloud.git","directory":"services/control-plane/sdk"},"bugs":{"url":"https://github.com/Maybank01/agentrouter-cloud/issues"},"homepage":"https://agentrouter.top","scripts":{"clean":"node scripts/clean.mjs","typecheck":"tsc --noEmit -p tsconfig.esm.json","test":"vitest run","build":"npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && node scripts/finalize.mjs","prepack":"npm run typecheck && npm test && npm run build"},"_id":"@agentrouter-top/sdk@0.1.0","_integrity":"sha512-w+PVyii+cKrCOXr9XXt9VZGZeIXsLkxOMNIW+hMlzSSExA0DdpXHrs6x/oiz3cMgW7dVzypnBejBkBFuvC7sbg==","_resolved":"F:\\AgentTeam\\agentrouter-cloud\\.artifacts\\sdk\\agentrouter-top-sdk-0.1.0.tgz","_from":"file:.artifacts/sdk/agentrouter-top-sdk-0.1.0.tgz","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-w+PVyii+cKrCOXr9XXt9VZGZeIXsLkxOMNIW+hMlzSSExA0DdpXHrs6x/oiz3cMgW7dVzypnBejBkBFuvC7sbg==","shasum":"61e3b98c8d35890378bcc163acdb3dd2b20133c5","tarball":"https://registry.npmjs.org/@agentrouter-top/sdk/-/sdk-0.1.0.tgz","fileCount":22,"unpackedSize":57597,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDhKAXUyIkZfAApURAFnsJRpu402rS9TtzvRNUHXMoH+QIgB9gSLA0juucs+07NywIpqHuJEx+DcRgD2AtIOnOMnaM="}]},"_npmUser":{"name":"maybank01","email":"z1316296346@gmail.com"},"directories":{},"maintainers":[{"name":"maybank01","email":"z1316296346@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1787913111897_0.352506189111339"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-28T10:31:51.683Z","0.1.0":"2026-08-28T10:31:52.047Z","modified":"2026-08-28T10:31:52.426Z"},"maintainers":[{"name":"maybank01","email":"z1316296346@gmail.com"}],"description":"Official server-side TypeScript SDK for AgentRouter management and analytics APIs.","homepage":"https://agentrouter.top","repository":{"type":"git","url":"git+https://github.com/Maybank01/agentrouter-cloud.git","directory":"services/control-plane/sdk"},"bugs":{"url":"https://github.com/Maybank01/agentrouter-cloud/issues"},"license":"MIT","readme":"# `@agentrouter-top/sdk`\n\nOfficial server-side TypeScript SDK for AgentRouter’s management and analytics APIs.\n\nThis package is for trusted backends. Keep the `aric_` Integration Credential in a server-side environment variable or secret manager. Never place it in browser code, a DSH/plugin sandbox, mobile code, a URL, or client logs.\n\n## Install\n\n```bash\nnpm install @agentrouter-top/sdk\n```\n\nNode.js 20.18 or newer is supported. Both ESM and CommonJS entry points are included.\n\n## Create and use a model API key\n\n```ts\nimport { AgentRouter } from \"@agentrouter-top/sdk\";\n\nconst agentrouter = new AgentRouter({\n  credential: process.env.AGENTROUTER_INTEGRATION_CREDENTIAL!,\n  // Use https://v3.agentrouter.top/api/integrations/v1 during V3 acceptance.\n  baseUrl: \"https://agentrouter.top/api/integrations/v1\",\n});\n\nconst created = await agentrouter.apiKeys.create(\n  {\n    name: \"little-tavern-production\",\n    modelIds: [\"deepseek-chat\"],\n  },\n  { idempotencyKey: crypto.randomUUID() },\n);\n\n// reveal() succeeds once. Persist the model key in your own server-side secret\n// manager before the value is consumed or the process exits.\nconst modelApiKey = created.secret.reveal();\n\nconst openAIConfig = agentrouter.openAIConfig(modelApiKey);\n// new OpenAI(openAIConfig)\n```\n\nAn Integration Credential manages account metadata, model keys and usage. It is not a model API key and cannot call the OpenAI-compatible `/v1` data plane. `openAIConfig` rejects management credentials to keep that boundary explicit.\n\n## Usage and analysis\n\n```ts\nconst range = {\n  startTime: new Date(Date.now() - 24 * 60 * 60 * 1000),\n  endTime: new Date(),\n};\n\nconst summary = await agentrouter.usage.summary(range);\nconst byModel = await agentrouter.analytics.breakdown({\n  ...range,\n  groupBy: \"model\",\n});\n\nfor await (const event of agentrouter.usage.iterateEvents(range)) {\n  console.log(event.request_id, event.model, event.raw_quota_units);\n}\n```\n\nUsage values come from the official NewAPI instance. AgentRouter does not create a second billing ledger for these endpoints. Responses include source, observation time and completeness metadata. They never contain prompts, responses, content, IP addresses, channels, providers or upstream credentials.\n\n## Errors and write safety\n\nEvery write requires an `idempotencyKey`. The SDK never retries writes automatically. If a connection fails after a write may have reached the server, it throws `AgentRouterError` with `unknownOutcome === true`; inspect the resource before retrying with the same key.\n\nSafe `GET` requests retry bounded `429`, `502`, `503`, `504` and network failures. All methods accept an `AbortSignal`, and errors expose a safe `requestId` when available.\n\n`OneTimeSecret` is redacted from JSON, string conversion, Node inspection and default error output. Closing or consuming it makes the plaintext unavailable through the SDK.\n\n## Read-only Team API\n\nThe Team API uses a separate `artm_` credential. Configure it only when the organization endpoints are needed:\n\n```ts\nconst agentrouter = new AgentRouter({\n  credential: process.env.AGENTROUTER_INTEGRATION_CREDENTIAL!,\n  teamCredential: process.env.AGENTROUTER_TEAM_CREDENTIAL!,\n});\n\nconst organization = await agentrouter.team.organization();\n```\n\nThe initial LittleTavern integration model is a dedicated backend service account. Per-user delegated authorization is a later consent/OAuth contract and is not emulated by this SDK.\n","readmeFilename":"README.md","_rev":"1-ea0986c7414a2db158dadbfb8880271f"}