{"_id":"@altsafe/aidirector","_rev":"8-1223f04fd3024dc53176387a6f68a4d5","name":"@altsafe/aidirector","dist-tags":{"latest":"1.6.0"},"versions":{"1.0.0":{"name":"@altsafe/aidirector","version":"1.0.0","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://aidirector.dev","name":"AI Director"},"license":"MIT","_id":"@altsafe/aidirector@1.0.0","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://aidirector.dev","bugs":{"url":"https://github.com/aidirector/client/issues"},"dist":{"shasum":"0d5775ab02ac93f39fe2300b63343c2ba95ebb1a","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.0.0.tgz","fileCount":7,"integrity":"sha512-LrhR+ElayZO6ODW6B989BX1X6FUWtGe9q8droxg4SLqXTvPfxQoYt3W569BcbmUE+hd9l748k3QHFyAW5KBn+w==","signatures":[{"sig":"MEQCIACKIZlG8gqWEww9gM34MnLhNQjymwuHQn8W/GWA0RDJAiBiWLlqoMhJKtKLgU57nCBzsHoOyR/tUAPbAUt5yaCrUw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55657},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/aidirector/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for AI Director - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.0.0_1766076717954_0.29107536984343096","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@altsafe/aidirector","version":"1.0.1","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://aidirector.dev","name":"AI Director"},"license":"MIT","_id":"@altsafe/aidirector@1.0.1","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://aidirector.dev","bugs":{"url":"https://github.com/aidirector/client/issues"},"dist":{"shasum":"08ef397a6fe948130892898d91ea7ea1d8d55cc8","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.0.1.tgz","fileCount":7,"integrity":"sha512-i1fKBlqEh0AnhOsV3uVCpTla+ZTizuuNkung1zxOb0tZNQFaXDGprLUykwvs7TzFG+wfZ/hh43Dbo6kSz0Mbsw==","signatures":[{"sig":"MEYCIQC+hp8OlWch5ogfFD7hK7/hBTRJPnMzsao+zrefYkMqAQIhALATTTkNinxWUZV4iYq8HK+zTfexqWn8XiY/7WQhh9Vq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59205},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/aidirector/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for AI Director - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.0.1_1766077083250_0.8123815077868886","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@altsafe/aidirector","version":"1.1.0","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://aidirector.dev","name":"AI Director"},"license":"MIT","_id":"@altsafe/aidirector@1.1.0","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://aidirector.dev","bugs":{"url":"https://github.com/aidirector/client/issues"},"dist":{"shasum":"399385c4615d4a474c304b35b1c6a1db711b5a15","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.1.0.tgz","fileCount":7,"integrity":"sha512-2xuU0KzP/Tt8NjFZM22gfKJ4QNbLq3Fwlq9nPjVjn5BUeVqWlVNdQuGGEBj21kTPtcrNgUXjZmvvm7E7WwKeNw==","signatures":[{"sig":"MEYCIQC+yx9WDzXxXN3bb1gbUJQjdBZMz2TcC0WDenzMPkjSQAIhAJjoIt1Z7GDM7uh5Gvkmpp6gK+ws97ZL+CKfA7SayJ8N","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":73629},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/aidirector/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for AI Director - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.1.0_1766427501401_0.39929227321863725","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@altsafe/aidirector","version":"1.2.0","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://aidirector.dev","name":"AI Director"},"license":"MIT","_id":"@altsafe/aidirector@1.2.0","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://aidirector.dev","bugs":{"url":"https://github.com/aidirector/client/issues"},"dist":{"shasum":"c9d889d33956a94133d89e33b288d105d27be8ee","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.2.0.tgz","fileCount":7,"integrity":"sha512-u8eASfpH40DhTjtEYc6fZ8gVnehydQYzozGR8v4b85EjQGJUIcBgk29BbrVSYiUAHJZX84pTnWpy5854+++WMw==","signatures":[{"sig":"MEYCIQD/hV7iX3cLVmBRzZj6kGMfefsQcMDSttl5KzV+/IUIzgIhAKtcA3lVPdKN7gZbNoJRSS7nM+J4Km+7klXacRWwNrKo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":73629},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/aidirector/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for AI Director - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.2.0_1766600410245_0.8490883083150731","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@altsafe/aidirector","version":"1.2.1","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://aidirector.dev","name":"AI Director"},"license":"MIT","_id":"@altsafe/aidirector@1.2.1","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://aidirector.dev","bugs":{"url":"https://github.com/aidirector/client/issues"},"dist":{"shasum":"6df4e8df3116e8279a8455aad3a71419b95e6bec","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.2.1.tgz","fileCount":7,"integrity":"sha512-6DMm2Ml9qx8rtGQQDN48WjqLRMwl4W8iQV1vivoFZAaEpqSwHjdLM2nTdCiwhuFj/wyRLRdSuko5iZ+8p34BAg==","signatures":[{"sig":"MEQCIDzrJcd8/ymujUBQXgMxLCA0F4iLLwKGDVUgnvY49g+nAiAwa/Kl6UUiqvw9xMT0Nl/Oy9OAFc2TpMFoyZEl6ZC5YQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":88333},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/aidirector/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for AI Director - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.2.1_1766695479872_0.5249756463500808","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"@altsafe/aidirector","version":"1.4.0","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://hydrai.dev","name":"Hydra"},"license":"MIT","_id":"@altsafe/aidirector@1.4.0","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://hydrai.dev","bugs":{"url":"https://github.com/hydrai/client/issues"},"dist":{"shasum":"7bac5122bf805ee007e641ccb3ffa25e92cd2db4","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.4.0.tgz","fileCount":7,"integrity":"sha512-DaOxWDIqMuEchgcx5E56DbVNgGO9V7o1YS6Jj9rfTLlE/ySgtBphSh+xmfP45d/9EKmxGsMRqiQbZlSa/plkAQ==","signatures":[{"sig":"MEUCIGtVXlBssymvO47GGitQ3pd84EJL4WAVtW49Wpnp+FChAiEA1cxsC4gmfsIfZzj6uTweXoFwt9PhVLqbr4weM6fY0Wc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89190},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish --access public","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/hydrai/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for Hydra - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.4.0_1769451933323_0.6137682940196385","host":"s3://npm-registry-packages-npm-production"}},"1.4.2":{"name":"@altsafe/aidirector","version":"1.4.2","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"url":"https://hydrai.dev","name":"Hydra"},"license":"MIT","_id":"@altsafe/aidirector@1.4.2","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"homepage":"https://hydrai.dev","bugs":{"url":"https://github.com/hydrai/client/issues"},"dist":{"shasum":"98511eadb73319a63906316ac412f25993c4f093","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.4.2.tgz","fileCount":7,"integrity":"sha512-rzgq4eL6VUvfkjR4P/IDkx/hlW+RAMhcFQ/T7HHzgMN3XnA/VMasOp+WMMfu1Ncb7qaJxIMTxN2EzqjGtDFKxA==","signatures":[{"sig":"MEQCIBiut+UebTsRS9+XyustAYpzS2Jd5UAcdk62jolP/BXoAiAVfKVcdzq1BSLe+ILeoepqOXA1h/5slt8lUDQUi7Y5kw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89229},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","clean":"rimraf dist","release":"npm run build && npm publish --access public","test:watch":"vitest","release:beta":"npm run build && npm publish --tag beta","release:dual":"node scripts/publish-dual.js","publish:check":"npm pack --dry-run","prepublishOnly":"npm run build"},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"repository":{"url":"git+https://github.com/hydrai/client.git","type":"git"},"_npmVersion":"11.6.2","description":"Official TypeScript SDK for Hydra - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.0","vitest":"^4.0.0","typescript":"^5.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aidirector_1.4.2_1769466316625_0.22768396386401268","host":"s3://npm-registry-packages-npm-production"}},"1.6.0":{"name":"@altsafe/aidirector","version":"1.6.0","description":"Official TypeScript SDK for Hydra - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","test:watch":"vitest","prepublishOnly":"npm run build","clean":"rimraf dist","publish:check":"npm pack --dry-run","release":"npm run build && npm publish --access public","release:dual":"node scripts/publish-dual.js","release:beta":"npm run build && npm publish --tag beta"},"keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"author":{"name":"Hydra","url":"https://hydrai.dev"},"license":"MIT","homepage":"https://hydrai.dev","bugs":{"url":"https://github.com/hydrai/client/issues"},"repository":{"type":"git","url":"git+https://github.com/hydrai/client.git"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"rimraf":"^5.0.0","tsup":"^8.0.0","typescript":"^5.0.0","vitest":"^4.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"engines":{"node":">=18.0.0"},"_id":"@altsafe/aidirector@1.6.0","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-dDerKjTlsqiJVzHwmkExwUXCi9FrdQVhLxny9BddocchoI6gMY/rHsB0Yu/7+Mlkt39DwNiXma2pvyMH1EmzJg==","shasum":"f1af3a6c85a0d24827430e887292436ca2884851","tarball":"https://registry.npmjs.org/@altsafe/aidirector/-/aidirector-1.6.0.tgz","fileCount":7,"unpackedSize":92928,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICeITFN7qKunr6Xnp3DWQzvTdjj9lax18Xcg5aM8vgAfAiEAy1pd6pWJJ5TuRtlSN+Aum1DoE/yMhDb4Di6mt/OihLg="}]},"_npmUser":{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"},"directories":{},"maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/aidirector_1.6.0_1769741093097_0.6335445155902211"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-18T16:51:57.822Z","modified":"2026-01-30T02:44:53.448Z","1.0.0":"2025-12-18T16:51:58.112Z","1.0.1":"2025-12-18T16:58:03.406Z","1.1.0":"2025-12-22T18:18:21.563Z","1.2.0":"2025-12-24T18:20:10.420Z","1.2.1":"2025-12-25T20:44:40.006Z","1.4.0":"2026-01-26T18:25:33.543Z","1.4.2":"2026-01-26T22:25:16.774Z","1.6.0":"2026-01-30T02:44:53.310Z"},"bugs":{"url":"https://github.com/hydrai/client/issues"},"author":{"name":"Hydra","url":"https://hydrai.dev"},"license":"MIT","homepage":"https://hydrai.dev","keywords":["ai","api","gateway","gemini","openrouter","openai","llm","fallback","sdk","typescript","json","cache","hmac"],"repository":{"type":"git","url":"git+https://github.com/hydrai/client.git"},"description":"Official TypeScript SDK for Hydra - Intelligent AI API Gateway with automatic failover, caching, and JSON extraction","maintainers":[{"name":"ruggedsimpa","email":"hereisadeveloper@gmail.com"}],"readme":"# hydra-aidirector\r\n\r\nThe official Node.js/TypeScript SDK for [Hydra](https://hydrai.dev) — a high-performance AI API gateway.\r\n\r\n[![npm version](https://badge.fury.io/js/hydra-aidirector.svg)](https://www.npmjs.com/package/hydra-aidirector)\r\n[![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.svg?v=101)](https://www.typescriptlang.org/)\r\n\r\n## Why Hydra?\r\n\r\n| Problem | Hydra Solution |\r\n|---------|----------------|\r\n| LLM outages break your app | 🔄 **Automatic Failover** – Seamless fallback between providers |\r\n| High latency & costs | ⚡ **God-Tier Caching** – Hybrid Redis + DB cache with AI-directed scoping |\r\n| Malformed JSON responses | 🛡️ **Self-Healing AI** – Auto-repair JSON, strip markdown, extract from prose |\r\n| Schema compliance issues | ✅ **Strict JSON Mode** – Force models to conform to your schema or fail |\r\n| No visibility into usage | 📊 **Detailed Analytics** – Track tokens, latency, and costs per model |\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install hydra-aidirector\r\n# or\r\npnpm add hydra-aidirector\r\n# or\r\nyarn add hydra-aidirector\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```typescript\r\nimport { Hydra } from 'hydra-aidirector';\r\n\r\nconst client = new Hydra({\r\n  secretKey: process.env.HYDRA_SECRET_KEY!, // hyd_sk_...\r\n  baseUrl: 'https://your-instance.vercel.app',\r\n});\r\n\r\n// Basic generation\r\nconst result = await client.generate({\r\n  chainId: 'my-chain',\r\n  prompt: 'Generate 5 user profiles as JSON',\r\n});\r\n\r\nif (result.success) {\r\n  console.log(result.data.valid); // Parsed, schema-validated objects\r\n}\r\n```\r\n\r\n---\r\n\r\n## Core Features\r\n\r\n### 🔄 Automatic Failover\r\nDefine fallback chains in your dashboard. If Gemini fails, Hydra automatically tries OpenRouter, Claude, etc.\r\n\r\n### 🛡️ Self-Healing JSON\r\nLLMs sometimes return broken JSON. Hydra extracts and repairs it automatically:\r\n\r\n```typescript\r\nconst result = await client.generate({ chainId: 'x', prompt: 'Get user' });\r\n\r\nif (result.meta.recovered) {\r\n  console.log('JSON was malformed but healed!');\r\n  console.log(result.data.healingReport);\r\n  // [{ original: \"{name: 'foo'\", healed: { name: \"foo\" }, fixes: [\"Added closing brace\"] }]\r\n}\r\n```\r\n\r\n### ✅ Strict JSON Mode vs Self-Healing\r\n\r\nHydra's self-healing JSON repair **works in both modes**. The difference is how the model behaves:\r\n\r\n| Mode | Model Behavior | Healing Role |\r\n|------|----------------|--------------|\r\n| **Strict** (`strictJson: true`) | Model is **forced** to output pure JSON via native API constraints. Output is already clean. | Safety net — rarely needed since output is constrained. |\r\n| **Non-Strict** (`strictJson: false`) | Model outputs best-effort JSON (may include markdown, prose, or broken syntax). | Primary mechanism — extracts and repairs JSON from messy output. |\r\n\r\n```typescript\r\n// Strict mode - model constrained to pure JSON\r\nawait client.generate({\r\n  chainId: 'gemini-chain',\r\n  prompt: 'Extract invoice data',\r\n  schema: invoiceSchema,\r\n  strictJson: true, // No markdown, no explanations\r\n});\r\n\r\n// Non-strict mode - flexible output, Hydra heals as needed\r\nawait client.generate({\r\n  chainId: 'any-chain',\r\n  prompt: 'Generate a creative story with metadata',\r\n  schema: storySchema,\r\n  strictJson: false, // Allow model to be creative, Hydra extracts JSON\r\n});\r\n```\r\n\r\n---\r\n\r\n## Streaming (Recommended for Large Responses)\r\n\r\nProcess JSON objects as they arrive — perfect for UIs that need instant feedback:\r\n\r\n```typescript\r\nawait client.generateStream(\r\n  {\r\n    chainId: 'my-chain',\r\n    prompt: 'Generate 100 product descriptions',\r\n  },\r\n  {\r\n    onObject: (obj, index) => {\r\n      console.log(`Object ${index}:`, obj);\r\n      renderToUI(obj); // Render immediately!\r\n    },\r\n    onComplete: (result) => {\r\n      console.log(`Done! ${result.objectCount} objects`);\r\n    },\r\n    onError: (error) => {\r\n      console.error('Stream failed:', error);\r\n    },\r\n  }\r\n);\r\n```\r\n\r\n---\r\n\r\n## Batch Generation\r\n\r\nProcess multiple prompts in parallel with automatic error handling:\r\n\r\n```typescript\r\nconst result = await client.generateBatch('my-chain', [\r\n  { id: 'item1', prompt: 'Describe product A' },\r\n  { id: 'item2', prompt: 'Describe product B' },\r\n  { id: 'item3', prompt: 'Describe product C' },\r\n]);\r\n\r\nconsole.log(`Processed ${result.summary.succeeded}/${result.summary.total}`);\r\n```\r\n\r\n---\r\n\r\n## Caching\r\n\r\n### Cache Scope\r\nControl how responses are cached:\r\n\r\n```typescript\r\n// Global cache (shared across users - default)\r\nawait client.generate({ chainId: 'x', prompt: 'Facts', cacheScope: 'global' });\r\n\r\n// User-scoped cache (private to authenticated user)\r\nawait client.generate({ chainId: 'x', prompt: 'My profile', cacheScope: 'user' });\r\n\r\n// Skip cache entirely\r\nawait client.generate({ chainId: 'x', prompt: 'Random', cacheScope: 'skip' });\r\n```\r\n\r\n### Cache Quality\r\nControl the trade-off between cache hit rate and precision:\r\n\r\n| Level | Behavior |\r\n|-------|----------|\r\n| `STANDARD` | Balanced fuzzy matching. Good for most cases. |\r\n| `HIGH` | Stricter matching. Higher quality hits, lower hit rate. |\r\n| `MAX_EFFICIENCY` | Aggressive matching. Maximum cost savings, less precision. |\r\n\r\n```typescript\r\nawait client.generate({\r\n  chainId: 'my-chain',\r\n  prompt: 'Generate report',\r\n  cacheQuality: 'MAX_EFFICIENCY', // Maximize cache hits\r\n});\r\n```\r\n\r\n### AI-Directed Caching\r\nThe AI can override cache scope by including a `_cache` directive in its output:\r\n\r\n```json\r\n{\r\n  \"data\": { \"...\": \"...\" },\r\n  \"_cache\": { \"scope\": \"user\" }\r\n}\r\n```\r\n\r\nThe directive is automatically stripped from your final response.\r\n\r\n---\r\n\r\n## File Attachments\r\n\r\nUpload documents for analysis. Hydra handles type detection and model compatibility:\r\n\r\n```typescript\r\nimport fs from 'fs';\r\n\r\nconst fileBuffer = fs.readFileSync('report.pdf');\r\n\r\nconst result = await client.generate({\r\n  chainId: 'document-analysis',\r\n  prompt: 'Summarize this document',\r\n  files: [{\r\n    data: fileBuffer.toString('base64'),\r\n    filename: 'report.pdf',\r\n    mimeType: 'application/pdf',\r\n  }],\r\n});\r\n```\r\n\r\n---\r\n\r\n## Request Cancellation\r\n\r\nCancel long-running requests with `AbortSignal`:\r\n\r\n```typescript\r\nconst controller = new AbortController();\r\nsetTimeout(() => controller.abort(), 5000); // Cancel after 5s\r\n\r\ntry {\r\n  const result = await client.generate({\r\n    chainId: 'my-chain',\r\n    prompt: 'Long task',\r\n    signal: controller.signal,\r\n  });\r\n} catch (error) {\r\n  if (error instanceof TimeoutError) {\r\n    console.log('Request was cancelled');\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n## Thinking Mode\r\n\r\nEnable reasoning models to show their thought process:\r\n\r\n```typescript\r\nconst result = await client.generate({\r\n  chainId: 'reasoning-chain',\r\n  prompt: 'Solve this complex problem step by step',\r\n  options: {\r\n    thinkingMode: true,\r\n  },\r\n});\r\n```\r\n\r\n---\r\n\r\n## Webhooks\r\n\r\nRegister callbacks for async notifications:\r\n\r\n```typescript\r\n// Register\r\nawait client.registerWebhook({\r\n  requestId: 'req_123',\r\n  url: 'https://your-domain.com/webhooks/hydra',\r\n  secret: 'your-webhook-secret',\r\n  retryCount: 3,\r\n});\r\n\r\n// Manage\r\nconst webhooks = await client.listWebhooks();\r\nawait client.updateWebhook('webhook_id', { retryCount: 5 });\r\nawait client.unregisterWebhook('webhook_id');\r\n```\r\n\r\n---\r\n\r\n## Configuration Reference\r\n\r\n### Client Options\r\n\r\n| Option | Type | Default | Description |\r\n|--------|------|---------|-------------|\r\n| `secretKey` | `string` | **required** | Your API key (`hyd_sk_...`) |\r\n| `baseUrl` | `string` | `http://localhost:3000` | API base URL |\r\n| `timeout` | `number` | `600000` | Request timeout in ms (10 min) |\r\n| `maxRetries` | `number` | `3` | Max retry attempts |\r\n| `debug` | `boolean` | `false` | Enable debug logging |\r\n\r\n### Generate Options\r\n\r\n| Option | Type | Default | Description |\r\n|--------|------|---------|-------------|\r\n| `chainId` | `string` | **required** | Fallback chain ID |\r\n| `prompt` | `string` | **required** | The prompt to send |\r\n| `schema` | `object` | - | JSON schema for validation |\r\n| `cacheScope` | `'global' \\| 'user' \\| 'skip'` | `'global'` | Cache sharing behavior |\r\n| `cacheQuality` | `'STANDARD' \\| 'HIGH' \\| 'MAX_EFFICIENCY'` | `'STANDARD'` | Cache match precision |\r\n| `strictJson` | `boolean` | `true` | Force strict JSON mode |\r\n| `signal` | `AbortSignal` | - | Cancellation signal |\r\n| `maxRetries` | `number` | Client default | Override retries |\r\n| `requestId` | `string` | Auto-generated | Custom request ID |\r\n| `files` | `FileAttachment[]` | - | File attachments |\r\n| `useOptimized` | `boolean` | `true` | Use 3-step cost-saving flow |\r\n| `noCache` | `boolean` | `false` | Skip cache entirely |\r\n\r\n---\r\n\r\n## API Methods\r\n\r\n| Method | Description |\r\n|--------|-------------|\r\n| `generate(options)` | Generate content with fallback chain |\r\n| `generateStream(options, callbacks)` | Stream JSON objects in real-time |\r\n| `generateBatch(chainId, items)` | Process multiple prompts |\r\n| `listModels()` | List available AI models |\r\n| `listChains()` | List your fallback chains |\r\n| `getUsage(options)` | Get usage statistics |\r\n| `health()` | Check API health |\r\n| `healthDetailed()` | Get detailed component health |\r\n| `registerWebhook(config)` | Register async webhook |\r\n| `unregisterWebhook(id)` | Remove a webhook |\r\n| `listWebhooks()` | List all webhooks |\r\n| `updateWebhook(id, updates)` | Modify webhook config |\r\n\r\n---\r\n\r\n## Error Handling\r\n\r\n```typescript\r\nimport {\r\n  RateLimitError,\r\n  TimeoutError,\r\n  AuthenticationError,\r\n  QuotaExceededError,\r\n  WorkerError,\r\n  FileProcessingError,\r\n  isRetryableError,\r\n} from 'hydra-aidirector';\r\n\r\ntry {\r\n  const result = await client.generate({ chainId: 'x', prompt: 'y' });\r\n} catch (error) {\r\n  if (error instanceof RateLimitError) {\r\n    console.log(`Retry after ${error.retryAfterMs}ms`);\r\n  } else if (error instanceof QuotaExceededError) {\r\n    console.log(`Quota exceeded: ${error.used}/${error.limit} (${error.tier})`);\r\n  } else if (error instanceof TimeoutError) {\r\n    console.log(`Timed out after ${error.timeoutMs}ms`);\r\n  } else if (error instanceof AuthenticationError) {\r\n    console.log('Invalid API key');\r\n  } else if (error instanceof WorkerError) {\r\n    console.log('Worker failed - will retry');\r\n  } else if (error instanceof FileProcessingError) {\r\n    console.log(`File error: ${error.reason} - ${error.filename}`);\r\n  } else if (isRetryableError(error)) {\r\n    console.log('Transient error - safe to retry');\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n## Pricing\r\n\r\n**BYOK (Bring Your Own Key)** — You pay AI providers directly. Hydra charges only for API access:\r\n\r\n| Tier | Price/mo | Requests | Overage |\r\n|------|----------|----------|---------|\r\n| Free | $0 | 1,000 | Blocked |\r\n| Starter | $9 | 25,000 | $0.50/1K |\r\n| Pro | $29 | 100,000 | $0.40/1K |\r\n| Scale | $79 | 500,000 | $0.30/1K |\r\n\r\n---\r\n\r\n## TypeScript Support\r\n\r\nFull type safety with comprehensive types:\r\n\r\n```typescript\r\nimport type {\r\n  GenerateOptions,\r\n  GenerateResult,\r\n  StreamCallbacks,\r\n  FileAttachment,\r\n  ChainInfo,\r\n  ModelInfo,\r\n} from 'hydra-aidirector';\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Node.js 18+\r\n- TypeScript 5+ (optional but recommended)\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT © [Hydra](https://hydrai.dev)\r\n","readmeFilename":"README.md"}