{"_id":"@genesis-xyz/ai","_rev":"7-2440e27d9e00cf69b95f403329bd26f1","name":"@genesis-xyz/ai","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.1":{"name":"@genesis-xyz/ai","version":"0.0.1","module":"src/index.ts","type":"module","dependencies":{"@passes/reqs":"^0.1.3"},"gitHead":"f65ccbd2d2215133a1dc40dba884b4e862082f5d","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.1","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-m9IUPRmOQtTMxlC343wUkxI1STPxII/4f7Hvk7Au42Gdq5Ozh7Z+qindYJ4nwCk7ZoW8MV8oaB3TMpe5PCo2yA==","shasum":"7ff689df520150225edc65fbe72e498cf6e8cf31","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.1.tgz","fileCount":5,"unpackedSize":3601,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH1OZVoV6jSyrldeBqZ0X2HdiQkINLdS7sZzDG9+fsTmAiEAmtpbSaDQaqX3VjnkPCuoL3QfFmaFFy1ZnofyXV/Qtnk="}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.1_1705648769913_0.9948848719594141"},"_hasShrinkwrap":false},"0.0.2":{"name":"@genesis-xyz/ai","version":"0.0.2","type":"module","main":"src/index.js","module":"src/index.js","types":"types/index.d.ts","scripts":{"build":"tsc"},"dependencies":{"@passes/reqs":"^0.1.3"},"exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"gitHead":"c59cde60b402eea911a3a4801c1f2704777232e0","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.2","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Zwv1QgU5inwckHby9Qmy3rN1Z9Rryn8xmk6K5Uq1kRVTHGoDxoiZuftXaptSWFRgszMgDAsVmrg2zcIZQBUypg==","shasum":"ffe77f69feb97a678fab165258da04469f37dd4d","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.2.tgz","fileCount":5,"unpackedSize":3805,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGSxiJcqWe8DOOKzG7IIMDq6rMHJClCihsMzA1sfM2dTAiBF+wXVHDQ61wITmxGM6IKVTrLE4fncboj/x89xrAyUFg=="}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.2_1705649238695_0.9774028082833441"},"_hasShrinkwrap":false},"0.0.3":{"name":"@genesis-xyz/ai","version":"0.0.3","type":"module","main":"src/index.js","module":"src/index.js","types":"types/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"tsc"},"dependencies":{"@passes/reqs":"^0.1.3"},"exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"gitHead":"9ff28060de61cbd07fd53d4d2c83cb8e63ae2d74","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.3","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-cvxDPuU0BIC0/3QWb1GkI6ifEVfs1N2IF/4XJB0QmCsHsYVthF3dG+kIQaiMRmQGJjLNaNSAcd1bFsMdiOF4kw==","shasum":"511d0f1bfd76ddc4fbf6e3d3038d84e080b45ff9","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.3.tgz","fileCount":5,"unpackedSize":4009,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC8iv85iM+rO1MK+m4k9KcOVfrRahyarQAWuvq3XkC0dQIhAP28BPuSAjplPuyMecJzhbTAvAyFamIn2bYgXVQ9wFW2"}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.3_1705649600464_0.4955194093984958"},"_hasShrinkwrap":false},"0.0.4":{"name":"@genesis-xyz/ai","version":"0.0.4","main":"src/index.js","module":"src/index.js","exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc","prepublishOnly":"tsc"},"type":"module","types":"types/index.d.ts","dependencies":{"@passes/reqs":"^0.1.4"},"gitHead":"79e64d6855900855f525b6548ada495472c17064","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.4","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Bw1Fz5mwoZPOtbD85WV4HotLDTEiE+l4T7hfyySPaApXJRyiVGeOiJ9d4H2hHmpFpTAeZrtSUHprfVT0zlIMsQ==","shasum":"fcac50bf8b8a89ccc86b9bec80e8b18ef65ac47e","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.4.tgz","fileCount":5,"unpackedSize":4009,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIES/Z6CPbmmH4KMzgwO+XcKzN9lNtXHwi2Vg/v/Qr3fZAiALTn/EUFYYhzLqyBfg2QUuUgJQHEEi18/cn6+wBUpAYg=="}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.4_1705697303346_0.4377784984548214"},"_hasShrinkwrap":false},"0.0.5":{"name":"@genesis-xyz/ai","version":"0.0.5","main":"src/index.js","module":"src/index.js","exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc","prepublishOnly":"tsc"},"type":"module","types":"types/index.d.ts","dependencies":{"@passes/reqs":"^0.1.5"},"gitHead":"e704220cb329ea212c93061783798187855196f4","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.5","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-MJgWd6+YY4TutCINoTByLyMk3owYO/mvzNgdnOUQqRkNPOQpTUMq2yP6PJ/7Xe8iod4uddsH/pXjNxluANb4GQ==","shasum":"cb320422c152a6213d797ed0bd8c2abd5a4523b3","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.5.tgz","fileCount":5,"unpackedSize":3943,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICvylJrFk3CbWvVdbKeBGZOUcOGPnjodrDTwkXKVu2QnAiBt1dy6zm+vSgbg+lPzDBpiAms1APyDe2H3c7pUaxL3Aw=="}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.5_1705785494082_0.2883090320744417"},"_hasShrinkwrap":false},"0.0.6":{"name":"@genesis-xyz/ai","version":"0.0.6","main":"src/index.js","module":"src/index.js","exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc"},"type":"module","types":"types/index.d.ts","dependencies":{"@passes/reqs":"^0.1.5"},"gitHead":"75e15de19a6b58bb47d4aaa3edcf0d81d5852307","description":"Request an OpenAI API to make requests on behalf of your user's OpenAI account. Your app, their API usage.","_id":"@genesis-xyz/ai@0.0.6","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-ovrg2zmAe7i8kQ6XW7vfqFXJa5sRjHkt/0IsqLvXAYrqV1ACw4MP80vuqy4WElHa1RAl0lQ3OcG46p4NZy1MdA==","shasum":"ebaed35128a913cc34dfda6c971a7c287051929d","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.6.tgz","fileCount":5,"unpackedSize":3888,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDk0aTJwtcZUZl4NyXDuVwEFy1o3zB62ind8ZLiP4mNQwIhAIPvD604wVfMMjN4JKTIyYwxV4P/uX8Rs30f2UOsQm5O"}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.6_1706034671563_0.3520130058921547"},"_hasShrinkwrap":false},"0.0.7":{"name":"@genesis-xyz/ai","version":"0.0.7","main":"src/index.js","module":"src/index.js","exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc"},"type":"module","types":"types/index.d.ts","dependencies":{"@passes/reqs":"^0.1.5"},"homepage":"https://github.com/genesis-xyz/ai","repository":{"type":"git","url":"git+ssh://git@github.com/genesis-xyz/ai.git"},"keywords":["ai","openai","sign in","auth","passes","genesis"],"gitHead":"2c3cfea5bb554e9a2ad4006ed5194810f1e32132","description":"Auth that enables users to sign in with their own OpenAI API key, so that you can build apps powered by users. Your app, their API usage.","bugs":{"url":"https://github.com/genesis-xyz/ai/issues"},"_id":"@genesis-xyz/ai@0.0.7","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-w76v+YTnrKJgEZ27++5pwS4QyzUx7MjoMqWHgr6qIr9dMproFeVxiGq5Y0M7xcxPDGILCyO8wU1x3wYdACN1hw==","shasum":"b4ed8d4176d639dc8ad4903305f5b54541077fae","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.7.tgz","fileCount":6,"unpackedSize":9517,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCtSichyWNfD/IspU55l5fA9I4TAaP35qg0xiEZnHx4igIhAJi2YZqCeqKbVfbQKZh4yrfW5H5L5SIvifw5W5nVCUEb"}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.7_1706115912318_0.1670814606632729"},"_hasShrinkwrap":false},"0.0.8":{"name":"@genesis-xyz/ai","version":"0.0.8","main":"src/index.js","module":"src/index.js","exports":{".":{"types":"./types/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc"},"type":"module","types":"types/index.d.ts","dependencies":{"@passes/reqs":"^0.1.5"},"license":"MIT","homepage":"https://github.com/genesis-xyz/ai","repository":{"type":"git","url":"git+ssh://git@github.com/genesis-xyz/ai.git"},"keywords":["ai","openai","sign in","auth","passes","genesis"],"gitHead":"73120019734a9fd84d7a147befb6de36ed5db777","description":"Auth that enables users to sign in with their own OpenAI API key, so that you can build apps powered by users. Your app, their API usage.","bugs":{"url":"https://github.com/genesis-xyz/ai/issues"},"_id":"@genesis-xyz/ai@0.0.8","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-PiM173DLrimGeEkE4j88b+wW5XEMah9kGSdCElWrgZqUTJVRqLFPY1mPnyEWMnhtHOM1F6qF6NTWYUNQyMdy1w==","shasum":"dab045db6f1085f41526acde266703afa2e0fae7","tarball":"https://registry.npmjs.org/@genesis-xyz/ai/-/ai-0.0.8.tgz","fileCount":6,"unpackedSize":9537,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqUnrXjfPbUewGUX0UOtevzTTcglsJ41U5zfQ+mWR3aAIgBP7Cvog4I0WdA701GP5NYaorx8HeJ0aJC88gIY/Vzsc="}]},"_npmUser":{"name":"danscan","email":"dan@dscanlon.com"},"directories":{},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ai_0.0.8_1706115962768_0.688366300470018"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-19T07:19:29.798Z","0.0.1":"2024-01-19T07:19:30.060Z","modified":"2024-01-24T17:06:03.340Z","0.0.2":"2024-01-19T07:27:18.842Z","0.0.3":"2024-01-19T07:33:20.623Z","0.0.4":"2024-01-19T20:48:23.584Z","0.0.5":"2024-01-20T21:18:14.252Z","0.0.6":"2024-01-23T18:31:11.766Z","0.0.7":"2024-01-24T17:05:12.555Z","0.0.8":"2024-01-24T17:06:03.069Z"},"maintainers":[{"name":"danscan","email":"dan@dscanlon.com"}],"description":"Auth that enables users to sign in with their own OpenAI API key, so that you can build apps powered by users. Your app, their API usage.","readme":"## Sign In With AI\n\nAuth that enables users to sign in with their own OpenAI API key, so that you can build apps powered by users. Your app, their API usage.\n\nUser OpenAI API keys will not be shared with your app. Instead, your app will receive an `apiKey` and `baseURL` for a proxy to the OpenAI API which uses your user's API keys.\n\n## Why build apps using Sign In With AI?\n\nBecause we believe it should be easier for developers to experiment and build new ideas for AI apps. \n\nFor each new app they build, developers also become responsible for the cost of using the OpenAI API and apps that leverage cutting-edge models like GPT-4 can carry a large bill if usage grows. Multiply that cost burden across several app ideas and that's a lot of overhead, making it harder to justify building new app ideas.\n\nAs a result, it’s becoming increasingly common to allow users to paste their personal OpenAI API key directly into the app. Not only is this bad security, it’s also super annoying for users to manually paste their API key in every new app that they want to try. \n\nBy offering a way for users to sign in with their own OpenAI API key, Genesis provides a safer way for users to try more AI apps and empowers developers to build their app ideas more easily, without taking on all of the cost burden for compute. It’s a win-win for everyone involved.\n\n### Installation\n\n```bash\nbun add @genesis-xyz/ai\n```\n\n‼️ Add this script to the `<head>` tag of your site:\n\n```html\n<script src=\"https://unpkg.com/@passes/polyfill@^0.1.5\"></script>\n```\n\n### Usage\n\n`requestOpenAIAPI` returns the following type, which may be passed directly to the `OpenAI` sdk constructor.\n\n```typescript\ntype RequestOpenAIAPIResult = {\n  apiKey: string;\n  baseURL: string;\n};\n```\n\n#### With the `openai` sdk: \n\n```typescript\nimport { requestOpenAIAPI } from '@genesis-xyz/ai';\nimport { OpenAI } from 'openai';\n\n// Request the user to \"Sign In With OpenAI\"\nconst openai = new OpenAI(await requestOpenAIAPI());\n\nconst chat = await openai.chat.completions.create({\n  model: 'gpt-4',\n  stream: true,\n  messages: [{ role: 'user', content: 'Hello OpenAI!' }],\n});\n```\n\n#### With client-side `fetch`:\n\n```typescript\nimport { requestOpenAIAPI } from '@genesis-xyz/ai';\nimport { OpenAI } from 'openai';\n\n// Request the user to \"Sign In With OpenAI\"\nconst { baseURL, apiKey } = await requestOpenAIAPI();\n\n// Use fetch to request the OpenAI API\nconst result = await fetch(`${baseURL}/chat/completions`, {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${apiKey}`,\n    'Content-Type': 'application/json',\n  },\n  body: JSON.stringify({\n    model: 'gpt-4',\n    messages: [{ role: 'user', content: 'Hello OpenAI!' }],\n  }),\n})\n```\n\n\n## FAQ\n\n<details>\n  <summary>How does it work?</summary>\n\n  #### Requesting an OpenAI API key from the user\n\n  1. When a user first signs up for your app, a new tab opens and requests the user to enter their OpenAI API key and secure it with a Passkey.\n  2. The API key is encrypted and stored for easy future access.\n  3. Your app gets an `apiKey` and `baseURL` that it can use to configure the `openai` SDK.\n\n  #### Proxying the the OpenAI API\n  \n  1. Your app sends requests to the provided `baseURL`, which is a proxy to OpenAI's API.\n  2. The proxy sends requests to OpenAI with the user's OpenAI API key.\n  3. Responses from OpenAI are streamed to your app.\n</details>\n\n<details>\n  <summary>How is user data secured?</summary>\n  \n  - **Encrypted API keys**. User API keys are wrapped in (encrypted) JWTs for both storage and transmission, meaning the key is never directly exposed to the requesting site or transmitted over the network in plain text.\n  - **Reverse proxy**. Genesis hosts a secure intermediary layer for proxying OpenAI API requests, which handles decrypting the user's API key, and forwarding the request to OpenAI. The reverse proxy allows the client to use the full functionality of the OpenAI API (including streaming) without ever handling the user API key.\n</details>\n\n\n## For users: How do I get an OpenAI API key?\n\nFor now, it’s a manual process:\n\n1. If you already have an OpenAI account, sign in [on the developer platform](https://platform.openai.com/). If not, sign up for an account here.\n    \n   <img width=\"1512\" alt=\"oai-dev-platform\" src=\"https://github.com/genesis-xyz/ai/assets/1638987/0c450c17-9968-4704-92dc-bba72dc099f6\">\n    \n2. To get an API key, click the [lock icon](https://platform.openai.com/api-keys) in the left-side toolbar.\n    \n    <img width=\"1512\" alt=\"dev-platform-sidebar-toggle\" src=\"https://github.com/genesis-xyz/ai/assets/1638987/4870456b-7d51-4e21-94f6-d24628346de1\">\n\n3. You’ll see all of the API keys that you’ve created on this page. To create a new API key, select `Create new secret key`, give it a name, and then copy the API key that appears. \n    - Note: any previously created API keys can’t be retrieved from this page, so be sure to save the key when you create it.\n    \n    <img width=\"1512\" alt=\"api-key-list\" src=\"https://github.com/genesis-xyz/ai/assets/1638987/6d67ff7c-2986-41a4-9de2-f900516793d3\">\n    \n4. Paste the API key in the text field and approve the request.\n    \n    <img width=\"1728\" alt=\"genesis-request\" src=\"https://github.com/genesis-xyz/ai/assets/1638987/50edcd88-dbee-4bc4-b3d6-e80262d43de0\">\n","readmeFilename":"README.md","homepage":"https://github.com/genesis-xyz/ai","keywords":["ai","openai","sign in","auth","passes","genesis"],"repository":{"type":"git","url":"git+ssh://git@github.com/genesis-xyz/ai.git"},"bugs":{"url":"https://github.com/genesis-xyz/ai/issues"},"license":"MIT"}