{"_id":"@aarvian-tech/nexus-llm","name":"@aarvian-tech/nexus-llm","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@aarvian-tech/nexus-llm","version":"1.1.0","description":"Official TypeScript/JavaScript SDK for the Centralized LLM Platform","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","type":"module","author":{"name":"Aarvian"},"repository":{"type":"git","url":"git+https://github.com/aarvian-tech/Centralize-llm-service.git"},"scripts":{"build":"tsc","test":"vitest run"},"dependencies":{"zod":"^3.22.0"},"devDependencies":{"typescript":"^5.0.0","vitest":"^1.0.0"},"_id":"@aarvian-tech/nexus-llm@1.1.0","gitHead":"4bf08ac1737f7fd987910e813ed0fa4273d71b41","bugs":{"url":"https://github.com/aarvian-tech/Centralize-llm-service/issues"},"homepage":"https://github.com/aarvian-tech/Centralize-llm-service#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-bE+qiTazOwi0/dHnbK9LwREFbQsG2svRdPAZP67UyfqHBJkbZ4zO+Nb9NlTfA8qUc/swZXPDeutSZTB+6xK6hA==","shasum":"db81c8b67398b460c0265565fae550963ab8c94b","tarball":"https://registry.npmjs.org/@aarvian-tech/nexus-llm/-/nexus-llm-1.1.0.tgz","fileCount":34,"unpackedSize":61952,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICslSMNFZuHXr3FyKqpCB3SLf1+cQqsN4guCmLvQHL2gAiAiho+gO9+Z7YjwGfHYM16O50YZ1vaEc7zbJCTM6Jb8Cg=="}]},"_npmUser":{"name":"anurag-aarvian","email":"anurag.singh@aarvian.com"},"directories":{},"maintainers":[{"name":"anurag-aarvian","email":"anurag.singh@aarvian.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nexus-llm_1.1.0_1786389877541_0.4992541499471439"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-10T19:24:37.412Z","1.1.0":"2026-08-10T19:24:37.823Z","modified":"2026-08-10T19:24:37.993Z"},"maintainers":[{"name":"anurag-aarvian","email":"anurag.singh@aarvian.com"}],"description":"Official TypeScript/JavaScript SDK for the Centralized LLM Platform","homepage":"https://github.com/aarvian-tech/Centralize-llm-service#readme","repository":{"type":"git","url":"git+https://github.com/aarvian-tech/Centralize-llm-service.git"},"author":{"name":"Aarvian"},"bugs":{"url":"https://github.com/aarvian-tech/Centralize-llm-service/issues"},"readme":"# NexusLLM TypeScript SDK\n\nOfficial ESM-first TypeScript/JavaScript client library for the Centralized LLM Platform (NexusLLM).\n\n## Installation\n\nInstall via npm, pnpm, or yarn:\n\n```bash\nnpm install @aarvian-tech/nexus-llm\n# or\npnpm add @aarvian-tech/nexus-llm\n# or\nyarn add @aarvian-tech/nexus-llm\n```\n\n## Quick Start\n\n### Simple Chat Completion\n\n```typescript\nimport { AIClient } from \"@aarvian-tech/nexus-llm\";\n\nasync function main() {\n  const client = new AIClient({ apiKey: \"your-nexus-api-key\" });\n\n  const response = await client.chat.create(\"my-custom-agent\", [\n    { role: \"user\", content: \"Hello! Introduce yourself.\" }\n  ]);\n\n  console.log(response.choices[0].content);\n}\n\nmain();\n```\n\n### Streaming Chat\n\n```typescript\nimport { AIClient } from \"@aarvian-tech/nexus-llm\";\n\nasync function main() {\n  const client = new AIClient({ apiKey: \"your-nexus-api-key\" });\n\n  const stream = await client.chat.create(\"my-custom-agent\", [\n    { role: \"user\", content: \"Write a 3-paragraph story.\" }\n  ], { stream: true });\n\n  for await (const chunk of stream) {\n    process.stdout.write(chunk.content);\n  }\n}\n\nmain();\n```\n\n> `{ stream: true }` now correctly targets the server-sent-events `/chat/stream` endpoint under the hood (previously it mistakenly hit the non-streaming `/chat` endpoint). The final chunk carries a populated `usage` object; if the upstream provider fails mid-stream, iteration throws a `ProviderError`.\n\n### Tool Calling\n\n`tools` accepts raw OpenAI function-calling JSON schema; the response's\n`tool_calls` mirrors LangChain's own `ToolCall` shape. Streaming tool-call\narguments arrive incrementally via `tool_call_chunks` (partial JSON\nfragments keyed by `index`), not as one complete call. Not every\nmodel/provider is verified to support tools yet — the gateway returns\n`424` for one that isn't, rather than silently ignoring `tools`.\n\n```typescript\nconst tools = [{\n  type: \"function\",\n  function: {\n    name: \"get_weather\",\n    description: \"Get the current weather for a city.\",\n    parameters: {\n      type: \"object\",\n      properties: { city: { type: \"string\" } },\n      required: [\"city\"],\n    },\n  },\n}];\n\nconst response = await client.chat.create(\n  \"my-custom-agent\",\n  [{ role: \"user\", content: \"What's the weather in Delhi?\" }],\n  { tools, toolChoice: \"auto\" }\n);\n\nfor (const call of response.choices[0].tool_calls ?? []) {\n  console.log(call.name, call.args);\n}\n```\n\nModels that expose reasoning/thinking content (Claude's extended thinking,\nOpenAI's o-series) surface it on `choices[0].reasoning` — a separate field\nfrom `content`, never mixed in.\n\n## File Management\n\n```typescript\nimport { AIClient } from \"@aarvian-tech/nexus-llm\";\n\nasync function main() {\n  const client = new AIClient({ apiKey: \"your-nexus-api-key\" });\n\n  // List files owned by the caller\n  const files = await client.files.list();\n\n  // Get a presigned download URL for a specific file\n  const download = await client.files.get(files[0].file_id);\n  console.log(download.download_url);\n\n  // Delete a file\n  await client.files.delete(files[0].file_id);\n}\n\nmain();\n```\n\n## Agent Configuration\n\n```typescript\nimport { AIClient } from \"@aarvian-tech/nexus-llm\";\n\nasync function main() {\n  const client = new AIClient({ apiKey: \"your-nexus-api-key\" });\n\n  // Create or update an agent's provider/model configuration\n  const config = await client.agents.configure({\n    agent_id: \"my-custom-agent\",\n    provider: \"openai\",\n    model: \"gpt-4o\",\n    fallback_provider: \"anthropic\",\n    fallback_model: \"claude-3-5-sonnet\",\n  });\n\n  // Fetch the current configuration for an agent\n  const current = await client.agents.getConfig(\"my-custom-agent\");\n  console.log(current);\n}\n\nmain();\n```\n\n## Error Handling\n\nErrors are mapped to strongly-typed TypeScript classes:\n\n```typescript\nimport { AIClient, AuthenticationError, ValidationError } from \"@aarvian-tech/nexus-llm\";\n\nasync function run() {\n  const client = new AIClient({ apiKey: \"invalid-key\" });\n  try {\n    await client.chat.create(\"agent-1\", [{ role: \"user\", content: \"hi\" }]);\n  } catch (error) {\n    if (error instanceof AuthenticationError) {\n      console.error(\"API Key invalid or revoked.\");\n    } else if (error instanceof ValidationError) {\n      console.error(\"Input validation check failed:\", error.message);\n    } else {\n      console.error(\"Request failed:\", error);\n    }\n  }\n}\n```\n\n## Configuration Options\n\nWhen initializing the client, the following config object is accepted:\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `apiKey` | `string` | `process.env.NEXUS_API_KEY` | Nexus authorization key |\n| `baseUrl` | `string` | `process.env.NEXUS_BASE_URL` | Central gateway API url |\n| `timeout` | `number` | `30000` | Connection timeout in milliseconds |\n| `retries` | `number` | `3` | Maximum retry attempts |\n| `debug` | `boolean` | `false` | Turn on console logging diagnostics |\n","readmeFilename":"README.md","_rev":"1-57682f7d899aa75e00ebff8b12b4d9c5"}