{"_id":"@bytebitlabs/nest-openai","_rev":"7-a5af61788710adaf1620d33735be77e9","name":"@bytebitlabs/nest-openai","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"name":"@bytebitlabs/nest-openai","version":"0.1.0","license":"MIT","_id":"@bytebitlabs/nest-openai@0.1.0","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"3a738605d5b09f308d78a01b4727a82a016d3ad2","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-0.1.0.tgz","fileCount":20,"integrity":"sha512-jR3+MqdD7SKz02AQknJ8yo1H1Qt3REyaDGEXZ8TL0FT6k1+eJ9fYUgthl+0YOCCPsNHy0tTqUxRnQX26Db7Gpg==","signatures":[{"sig":"MEUCIE/pb3n4JuEW4KK6M4JXZq5IB+hDQ9mH2KXY8OGC4UJ5AiEAgi01zFAibnhWOYuIxVFNnmeZsEqt7BFNA3JR0QM3JDs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10959},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"7ef6f8df4e9fdc0b5484ffb606791b86197af767","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_0.1.0_1723730107136_0.5787647982290078","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@bytebitlabs/nest-openai","version":"0.1.1","license":"MIT","_id":"@bytebitlabs/nest-openai@0.1.1","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"c5d1bc195e3fd79d373bc3962f551a6eee996063","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-0.1.1.tgz","fileCount":20,"integrity":"sha512-tu1gM7TRNJ8PraqN+jv/0BYjQK/TnPHaMSEyUf8/V71kxQSLTT95fKj4WHLBJ/h8b+xsPVtHUtI90sHQn7f9lw==","signatures":[{"sig":"MEUCIDEvSo8DimoUqi3YbF8OGMoH7TQJ7d2tCJMW+gWRadl8AiEArn2lknflD+0m6y04H5+/SLEiHg3HX6epuFZynIW7piU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10959},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"9ac581ff68f03d00df4a88865f2f1744a9ed2656","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_0.1.1_1723745046083_0.1414562480421071","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"@bytebitlabs/nest-openai","version":"0.1.3","license":"MIT","_id":"@bytebitlabs/nest-openai@0.1.3","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"952d1909cafe42df62dbb6eef5edf16417bbf3dd","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-0.1.3.tgz","fileCount":20,"integrity":"sha512-EAWzRFPg+qeZQkpZHKPy2yubLmJUGEUwISLO3m5tHXRW95wU9Sp4G/lY14UeA68osF0NkAGjr0gzFOxzB5Obow==","signatures":[{"sig":"MEUCID09QRb46T3oO29kG6J6WMuJF5Def/r71P9MJn7w+Xe4AiEAvTPUFSSrjaMJp6O4l5S7f6G1/gQc5oknaYKCW13GMyk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10959},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"bd1b5bf77c1e81013bb06d56f6d802aea7440d43","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_0.1.3_1727159146852_0.5148105452580218","host":"s3://npm-registry-packages"}},"1.0.0-0":{"name":"@bytebitlabs/nest-openai","version":"1.0.0-0","license":"MIT","_id":"@bytebitlabs/nest-openai@1.0.0-0","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"07cd27df24614ccdc49fcbd6940b89ce7b180bc8","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-1.0.0-0.tgz","fileCount":20,"integrity":"sha512-qjQlNvRm2e2EFh51KOt3zY2hgrbCCYUcVpmdKrzjftBVS5WgcLC849vas3PaI+sK2I8t/7rH0V9+IEyUkMa7aQ==","signatures":[{"sig":"MEYCIQDFPZf+fpdHMjC8CxYcMNsGEx8Mv7jcJ/TpgI9xJ00JPwIhAJO3lGgEAoe9d4cHu1YE149q76UIJMMtqhcsXyi4CTo8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10961},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"ba9fcdf8beb2775837215e03b516a4157388989a","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_1.0.0-0_1731382843585_0.6288958682771664","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@bytebitlabs/nest-openai","version":"1.0.0","license":"MIT","_id":"@bytebitlabs/nest-openai@1.0.0","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"318de163ba8dca0a7cdf2e7832f72439248d4718","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-1.0.0.tgz","fileCount":20,"integrity":"sha512-jvKGWbpn/EC20XcuYqQ1QBOimapHEVMcQ85uQ3Ay78zERJvdFbY1h/PMEniOowYlWbkT+jJyWdND2+wMqQul5A==","signatures":[{"sig":"MEQCIBcx0kIVPWP+UJ0jJ50NwhWaDb0wav+7j5IeJIekbXEBAiAoXby7dZE1G0pU1C/iK8Q6f0S5rQ7Ez6/mz2xeJ88sFA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10959},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"b2be2b59aa13ee02489dfa1745f08fe31fe3b14f","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_1.0.0_1735549383092_0.025377670382146222","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bytebitlabs/nest-openai","version":"1.0.1","license":"MIT","_id":"@bytebitlabs/nest-openai@1.0.1","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"dist":{"shasum":"1edd6842662458587da2e252a1807dc933f1f570","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-1.0.1.tgz","fileCount":20,"integrity":"sha512-A/+FzplWpR7hi5sACFCvs07f6RrLsgIR/Sr5bt33y2RtM2Pu8Sx3Nb3NTKgy9sR803FIAidCMizjSVbpvCaXow==","signatures":[{"sig":"MEQCIEIVxGLLKnvunTKtBti2tybj4+KQUrSYiJvowR6OJpeGAiBOk4wZr3f1x3syal3YuzUu8RC9eagNavUEeEBy6xC5sw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10959},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"e3e3e03a508e6b132b6a366cd0bd02e9d01594cb","typings":"./src/index.d.ts","_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"_npmVersion":"10.5.2","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","directories":{},"_nodeVersion":"20.13.1","dependencies":{"tslib":"^2.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nest-openai_1.0.1_1737347957850_0.2679383068264305","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@bytebitlabs/nest-openai","version":"1.1.0","license":"MIT","dependencies":{"tslib":"^2.3.0"},"type":"commonjs","main":"./src/index.js","typings":"./src/index.d.ts","publishConfig":{"access":"public"},"types":"./src/index.d.ts","_id":"@bytebitlabs/nest-openai@1.1.0","gitHead":"e82f08bce74eb7b91dfd7fd7ffc0423f08ccaec5","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-nzadNqVMosg5CbRTGyJIN8hTgzByPrZF4UVwpm/eWNE2XE5Tasv7vgYVn5TdwVUFirVjbbVAkuQhbacKLAYkNg==","shasum":"1ce27d1e871b7f498e9f08bed0792ddd97128bd6","tarball":"https://registry.npmjs.org/@bytebitlabs/nest-openai/-/nest-openai-1.1.0.tgz","fileCount":20,"unpackedSize":10959,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC2nkn5MaqsUhUvPhfBsI+uF/zzVq8EQiH31EwoyXlnRwIhAIZyW9GeUvmPk9bO1Kqjz5MXVEc4B0Yn6m7y3HTkTYuf"}]},"_npmUser":{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"},"directories":{},"maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nest-openai_1.1.0_1741581818078_0.5770219769111524"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-15T13:55:07.051Z","modified":"2025-03-10T04:43:38.405Z","0.1.0":"2024-08-15T13:55:07.335Z","0.1.1":"2024-08-15T18:04:06.277Z","0.1.3":"2024-09-24T06:25:47.042Z","1.0.0-0":"2024-11-12T03:40:43.768Z","1.0.0":"2024-12-30T09:03:03.239Z","1.0.1":"2025-01-20T04:39:18.034Z","1.1.0":"2025-03-10T04:43:38.236Z"},"license":"MIT","description":"<p align=\"center\">   <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a> </p>","maintainers":[{"name":"bytebitlabs","email":"0xnairb@bytebitlabs.com"}],"readme":"# nest-openai\n\n<p align=\"center\">\n  <a href=\"https://bytebitlabs.com/\" target=\"_blank\"><img src=\"https://gravatar.com/avatar/61c80d73dfe4c4231e77940cf80fd410?size=256\" width=\"256\" alt=\"ByteBitLabs logo\" /></a>\n</p>\n\n<p align=\"center\">OpenAI module for nestjs</p>\n    <p align=\"center\">\n<a href=\"https://www.npmjs.com/package/@bytebitlabs/nest-openai\"><img src=\"https://img.shields.io/npm/v/@bytebitlabs/nest-openai\" alt=\"NPM Version\" /></a>\n<a href=\"https://www.npmjs.com/package/@bytebitlabs/nest-openai\"><img src=\"https://img.shields.io/npm/l/@bytebitlabs/nest-openai\" alt=\"Package License\" /></a>\n<a href=\"https://www.npmjs.com/package/@bytebitlabs/nest-openai\"><img src=\"https://img.shields.io/npm/dm/@bytebitlabs/nest-openai\" alt=\"NPM Downloads\" /></a>\n</p>\n\n## Description\n\nOpenAI module for [Nest](https://github.com/nestjs/nest) based on the official [openai](https://www.npmjs.com/package/openai) package.\n\n## Installation\n\n```bash\n$ npm i --save @bytebitlabs/nest-openai openai\n```\n\n## Usage\n\nImport `OpenAiModule`:\n\n```typescript\n@Module({\n  imports: [OpenAiModule.register({\n    apiKey: 'Abc...',\n  })],\n  providers: [...],\n})\nexport class AiModule {}\n```\n\nInject `OpenAiService`:\n\n```typescript\n@Injectable()\nexport class AiService {\n  constructor(private readonly openAiService: OpenAiService) {}\n}\n```\n\n## Async options\n\nQuite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use `registerAsync()` method, that provides a couple of various ways to deal with async data.\n\n**1. Use factory**\n\n```typescript\nOpenAiModule.registerAsync({\n  useFactory: () => ({\n    apiKey: 'Abc...'\n  })\n});\n```\n\nObviously, our factory behaves like every other one (might be `async` and is able to inject dependencies through `inject`).\n\n```typescript\nOpenAiModule.registerAsync({\n  imports: [ConfigModule],\n  useFactory: async (configService: ConfigService) => ({\n    apiKey: configService.get('OPENAI_API_KEY'),\n  }),\n  inject: [ConfigService],\n}),\n```\n\n**2. Use class**\n\n```typescript\nOpenAiModule.registerAsync({\n  useClass: OpenAiConfigService\n});\n```\n\nAbove construction will instantiate `OpenAiConfigService` inside `OpenAiModule` and will leverage it to create options object.\n\n```typescript\nclass OpenAiConfigService implements OpenaiOptionsFactory {\n  createOpenAiOptions(): OpenAiModuleOptions {\n    return {\n      apiKey: 'Abc...'\n    };\n  }\n}\n```\n\n**3. Use existing**\n\n```typescript\nOpenAiModule.registerAsync({\n  imports: [ConfigModule],\n  useExisting: ConfigService,\n}),\n```\n\nIt works the same as `useClass` with one critical difference - `OpenAiModule` will lookup imported modules to reuse already created `ConfigService`, instead of instantiating it on its own.\n\n## API Spec\n\nThe `OpenAiService` wraps the `Client` from the official [openai](https://www.npmjs.com/package/openai) methods. The `OpenAiModule.register()` takes `options` object as an argument, [read more](https://platform.openai.com/docs/overview).\n","readmeFilename":"README.md"}