{"_id":"@aethex.os/ai","_rev":"3-4a7eff4f01a7b0b8e1fbe3059cb80c9e","name":"@aethex.os/ai","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aethex.os/ai","version":"1.0.0","keywords":["ai","gemini","google-ai","chat","llm","function-calling","tool-use","express","middleware","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","_id":"@aethex.os/ai@1.0.0","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"homepage":"https://aethex.dev","bugs":{"url":"https://github.com/AeThex-Corporation/AeThex-OS/issues"},"dist":{"shasum":"cd3f2bd8506aac0e0e520d66c3d56b5265300766","tarball":"https://registry.npmjs.org/@aethex.os/ai/-/ai-1.0.0.tgz","fileCount":14,"integrity":"sha512-aU5TXN7iBXPrMTeuECjrfQWP+UDM+2R6boXMp31yy4VQGdYkluiMP7C15OO1ioafnynaiHSm1M8f6aLnEv0nBg==","signatures":[{"sig":"MEUCIBEsvYdY8T4o1L5k4kWP9TmF+zbNjgOoQag9/pYYVFi3AiEAqcxoyhvFHDKc7SxG0Wr0rV8Tc5lTzfdxTsFyPMwqbxo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16551},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"b094d5c032765a30612c2348ce0356d3a50d9feb","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"repository":{"url":"git+https://github.com/AeThex-Corporation/AeThex-OS.git","type":"git","directory":"packages/aethex-ai"},"_npmVersion":"11.12.1","description":"AI chat client for Node.js — Gemini integration with tool-calling, chat history, system instructions, and an Express middleware handler","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"devDependencies":{"express":"^4.18.0","typescript":"^5.3.0","@types/node":"^20.0.0","@google/genai":"^1.0.0","@types/express":"^4.17.0"},"peerDependencies":{"express":">=4.0.0","@google/genai":">=1.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/ai_1.0.0_1777933715818_0.707520849369494","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aethex.os/ai","version":"1.0.1","keywords":["ai","gemini","google-ai","chat","llm","function-calling","tool-use","express","middleware","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","_id":"@aethex.os/ai@1.0.1","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"homepage":"https://aethex.dev","bugs":{"url":"https://github.com/AeThex-Corporation/AeThex-OS/issues"},"dist":{"shasum":"a9081182539fbbcb94825f664e9a8f76bcf95210","tarball":"https://registry.npmjs.org/@aethex.os/ai/-/ai-1.0.1.tgz","fileCount":14,"integrity":"sha512-XJKPvJ0aQv+sf8YWDY1oqgM7BYsmMQ6bZS+pM82C9HLfRAdBXURykggEFT37K8YonGZH1Mgi84WC79kSodYrZA==","signatures":[{"sig":"MEYCIQDW4OfIP8jZzNZPyR5aMur9GNsPeQOq6gJQ4pmX8N6KaQIhANa37iNHvnIGPQQvll0AOry1O8KM1iFLYEAf0YmTF3g+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16600},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"b094d5c032765a30612c2348ce0356d3a50d9feb","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"repository":{"url":"git+https://github.com/AeThex-Corporation/AeThex-OS.git","type":"git","directory":"packages/aethex-ai"},"_npmVersion":"11.12.1","description":"AI chat client for Node.js — Gemini integration with tool-calling, chat history, system instructions, and an Express middleware handler","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"devDependencies":{"express":"^4.18.0","typescript":"^5.3.0","@types/node":"^20.0.0","@google/genai":"^1.0.0","@types/express":"^4.17.0"},"peerDependencies":{"express":">=4.0.0","@google/genai":">=1.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/ai_1.0.1_1777933774967_0.6777523035428132","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aethex.os/ai","version":"1.0.2","description":"AI chat client for Node.js — Gemini integration with tool-calling, chat history, system instructions, and an Express middleware handler","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch"},"keywords":["ai","gemini","google-ai","chat","llm","function-calling","tool-use","express","middleware","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-ai"},"peerDependencies":{"@google/genai":">=1.0.0","express":">=4.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"devDependencies":{"@google/genai":"^1.0.0","@types/express":"^4.17.0","@types/node":"^20.0.0","express":"^4.18.0","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"_id":"@aethex.os/ai@1.0.2","gitHead":"6c77abd6440deb925777f64998d4c67a398236e0","_nodeVersion":"22.22.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-LxIwRt0qY/W5wt7bysQSu8fQpVG55dxNERnH53R5HacUlbThRtupqvzUPCKO9mjyYxaF4j8WSldkTipGtakr/w==","shasum":"e8c7f81032c6468edbc7f5073b1044d6da80fe2b","tarball":"https://registry.npmjs.org/@aethex.os/ai/-/ai-1.0.2.tgz","fileCount":14,"unpackedSize":16662,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDw2q18Z0pOSpGqkkOrh9dhfuJt+HdY/J910ox3NqsEcwIgElZhNTBAz6WPWYabSvIXWXBZ9ZIWe74bW/UXEa7sII0="}]},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"directories":{},"maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai_1.0.2_1783400194904_0.9386294804452866"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-04T22:28:35.720Z","modified":"2026-07-07T04:56:35.167Z","1.0.0":"2026-05-04T22:28:35.977Z","1.0.1":"2026-05-04T22:29:35.109Z","1.0.2":"2026-07-07T04:56:35.048Z"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","keywords":["ai","gemini","google-ai","chat","llm","function-calling","tool-use","express","middleware","aethex"],"repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-ai"},"description":"AI chat client for Node.js — Gemini integration with tool-calling, chat history, system instructions, and an Express middleware handler","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"readme":"# @aethex.os/ai\n\nAI chat client for Node.js — Gemini with tool-calling, chat history, system instructions, and a drop-in Express handler.\n\n## Install\n\n```bash\nnpm install @aethex.os/ai @google/genai\n```\n\n## Basic usage\n\n```ts\nimport { createAiClient } from \"@aethex.os/ai\";\n\nconst ai = createAiClient({\n  apiKey: process.env.GEMINI_API_KEY!,\n  model: \"gemini-2.5-flash\", // default\n});\n\nconst { response } = await ai.chat(\"Explain WebSockets in one paragraph\");\nconsole.log(response);\n```\n\n## With chat history\n\n```ts\nconst { response } = await ai.chat(\"What was my last question?\", {\n  history: [\n    { role: \"user\", content: \"What is TypeScript?\" },\n    { role: \"model\", content: \"TypeScript is a typed superset of JavaScript...\" },\n  ],\n});\n```\n\n## With system instruction\n\n```ts\nconst ai = createAiClient({\n  apiKey: process.env.GEMINI_API_KEY!,\n  defaultSystemInstruction: \"You are a helpful customer support agent for Acme Corp.\",\n});\n\nconst reply = await ai.complete(\"How do I reset my password?\");\n```\n\n## With tool-calling\n\n```ts\nimport { createAiClient, ToolDefinition } from \"@aethex.os/ai\";\n\nconst tools: ToolDefinition[] = [\n  {\n    name: \"get_weather\",\n    description: \"Get current weather for a city\",\n    parameters: {\n      type: \"object\",\n      properties: {\n        city: { type: \"string\", description: \"City name\" },\n      },\n      required: [\"city\"],\n    },\n  },\n];\n\nconst { response, toolCallsMade } = await ai.chat(\"What's the weather in Tokyo?\", {\n  tools,\n  toolHandler: (name, args) => {\n    if (name === \"get_weather\") return { temp: \"22°C\", condition: \"Sunny\" };\n    return { error: \"unknown tool\" };\n  },\n});\n```\n\n## Express middleware\n\n```ts\nimport express from \"express\";\nimport { createAiClient, createAiChatHandler } from \"@aethex.os/ai\";\n\nconst app = express();\napp.use(express.json());\n\nconst ai = createAiClient({ apiKey: process.env.GEMINI_API_KEY! });\n\napp.post(\"/api/chat\", createAiChatHandler({ client: ai }));\n// POST body: { prompt: string, history?: ChatMessage[] }\n// Response: { response: string }\n```\n\n## API\n\n### `createAiClient(config)`\n| Option | Type | Description |\n|--------|------|-------------|\n| `apiKey` | `string` | Gemini API key |\n| `model` | `string` | Model ID (default: `gemini-2.5-flash`) |\n| `defaultSystemInstruction` | `string` | Default system prompt |\n\n### `ai.chat(prompt, opts?)`\nSends a message and returns `{ response, toolCallsMade? }`.\n\n### `ai.complete(prompt, systemInstruction?)`\nSingle-turn helper. Returns the response string directly.\n\n### `createAiChatHandler(config)`\nReturns an Express route handler for `POST /api/chat`.\n\n---\n\nPart of the [`@aethex.os`](https://www.npmjs.com/search?q=%40aethex.os) toolkit.\n","readmeFilename":"README.md"}