{"_id":"@bytarch/ai","_rev":"4-2406d67bfa40138a8070d142669fb6d8","name":"@bytarch/ai","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@bytarch/ai","version":"1.0.0","keywords":["AI","bytarch"],"author":{"name":"BytArch","email":"bytarchbit@gmail.com"},"license":"ISC","_id":"@bytarch/ai@1.0.0","maintainers":[{"name":"bytarch","email":"bytarchbit@gmail.com"}],"homepage":"https://github.com/bytarch/bytarch-node#readme","bugs":{"url":"https://github.com/bytarch/bytarch-node/issues"},"dist":{"shasum":"6e2b3eeaf731964f54e20adc9043a123536f2af8","tarball":"https://registry.npmjs.org/@bytarch/ai/-/ai-1.0.0.tgz","fileCount":10,"integrity":"sha512-bGAohI5UHv61gNnyty1U8qSfsWeKEYabKkJoHngY0dzHJjzZizFkg/G9vPh1myH3gXw8bhw8BtTgZF8Gm5GGVw==","signatures":[{"sig":"MEUCIDo406LAh6DJydz5MLcu+j+Yif35N7wm0rCkf8kugefOAiEA6+SiLsCPxhDbB23NJRdPNnvrR3nwFyeQEvy4fpI9xsM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19084},"main":"lib/index.js","type":"commonjs","scripts":{"testModels":"node test/testDisplay.js","chatStreaming":"node test/chatStreaming.js","chatGeneration":"node test/chatCompletion.js","imageGeneration":"node test/imageGeneration.js"},"_npmUser":{"name":"bytarch","email":"bytarchbit@gmail.com"},"repository":{"url":"git+https://github.com/bytarch/bytarch-node.git","type":"git"},"_npmVersion":"10.8.2","description":"The official javascript library for the BytArch API","directories":{},"_nodeVersion":"20.18.0","dependencies":{"node-fetch":"^3.3.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ai_1.0.0_1730067612339_0.6526246859279321","host":"s3://npm-registry-packages"}},"1.0.67":{"name":"@bytarch/ai","version":"1.0.67","keywords":["AI","bytarch"],"author":{"name":"BytArch","email":"bytarchbit@gmail.com"},"license":"ISC","_id":"@bytarch/ai@1.0.67","maintainers":[{"name":"bytarch","email":"bytarchbit@gmail.com"}],"homepage":"https://github.com/bytarch/bytarch-node#readme","bugs":{"url":"https://github.com/bytarch/bytarch-node/issues"},"dist":{"shasum":"d02b54b6d76b66b34443b48d4216679dfc62b63e","tarball":"https://registry.npmjs.org/@bytarch/ai/-/ai-1.0.67.tgz","fileCount":17,"integrity":"sha512-P/uh7h1ND0F6UXqD0tSR17HzS1KjMnoYpHGw1HHksxOotjcnhki11D5OJjDW+8B//xZ40GDGoJj0YMabF/fJxA==","signatures":[{"sig":"MEUCIQCYlSxTjhDTJMHiF84t+YSshicEe0D+V/teKsLGyMnVewIgchcfH7FvFzA67jgpO0sPKZjX0VUE3v4xB3kEy/nInJ4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30254},"main":"lib/index.js","type":"module","scripts":{"chat":"node test/chatCompletion.js","image":"node test/imageGeneration.js","models":"node test/testDisplay.js","stream":"node test/chatStreaming.js"},"_npmUser":{"name":"bytarch","email":"bytarchbit@gmail.com"},"repository":{"url":"git+https://github.com/bytarch/bytarch-node.git","type":"git"},"_npmVersion":"11.6.2","description":"The official javascript library for the BytArch API","directories":{},"_nodeVersion":"22.15.0","dependencies":{"openai":"^4.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ai_1.0.67_1761515247474_0.2874725101245723","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bytarch/ai","version":"1.2.0","keywords":["AI","bytarch"],"author":{"name":"BytArch","email":"bytarchbit@gmail.com"},"license":"ISC","_id":"@bytarch/ai@1.2.0","maintainers":[{"name":"bytarch","email":"bytarchbit@gmail.com"}],"homepage":"https://github.com/bytarch/bytarch-node#readme","bugs":{"url":"https://github.com/bytarch/bytarch-node/issues"},"dist":{"shasum":"797e54825f2eee057d7e93e06a71a3b624c15cb3","tarball":"https://registry.npmjs.org/@bytarch/ai/-/ai-1.2.0.tgz","fileCount":17,"integrity":"sha512-yT+20fgbLIU2rXqA96tLnxRr1eYN04EIWCi0MSCRZPGWRkRs4dQ8uKKz0HRQ7Q/Q5IdLTgv7yvyU/i70yisaZA==","signatures":[{"sig":"MEUCIQDSztmzcxri/T3X74+IHS64QCTFPIs1nImLLknV4f37VgIgTz1smN3X+dYkhR9Z+lf8UukGKfP/lzhpnxRxZVSNFHY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33178},"main":"lib/index.js","type":"module","scripts":{"chat":"node test/chatCompletion.js","image":"node test/imageGeneration.js","models":"node test/testDisplay.js","stream":"node test/chatStreaming.js"},"_npmUser":{"name":"bytarch","email":"bytarchbit@gmail.com"},"repository":{"url":"git+https://github.com/bytarch/bytarch-node.git","type":"git"},"_npmVersion":"11.6.2","description":"The official javascript library for the BytArch API","directories":{},"_nodeVersion":"22.15.0","dependencies":{"openai":"^4.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/ai_1.2.0_1762841353030_0.7839540491412829","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@bytarch/ai","version":"1.2.1","type":"module","description":"The official javascript library for the BytArch API","main":"lib/index.js","scripts":{"models":"node test/testDisplay.js","image":"node test/imageGeneration.js","chat":"node test/chatCompletion.js","stream":"node test/chatStreaming.js"},"repository":{"type":"git","url":"git+https://github.com/bytarch/bytarch-node.git"},"keywords":["AI","bytarch"],"author":{"name":"BytArch","email":"bytarchbit@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/bytarch/bytarch-node/issues"},"homepage":"https://github.com/bytarch/bytarch-node#readme","dependencies":{"openai":"^4.0.0"},"_id":"@bytarch/ai@1.2.1","_nodeVersion":"22.15.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-/uQf8c2wPSxStIIEePhZtojBPIqPKRFTq0D7Hxm+0Dx8LYY7tAP+hxip/KORUovaYPMUlzL6vy/hPqv23hsbYQ==","shasum":"7a527f0d70d53370a7339f2a47f46535a6991cda","tarball":"https://registry.npmjs.org/@bytarch/ai/-/ai-1.2.1.tgz","fileCount":17,"unpackedSize":34378,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIF+sE4KypG4K3V4APHQItZI9Xz8Qu4/SM09boNAWsi+aAiEAmiJQLIHaDjQf8D1gO7KuZ1rk7F9N/J3A5e2CHYQnAz0="}]},"_npmUser":{"name":"bytarch","email":"bytarchbit@gmail.com"},"directories":{},"maintainers":[{"name":"bytarch","email":"bytarchbit@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai_1.2.1_1762841917024_0.2837033678451397"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-27T22:20:12.254Z","modified":"2025-11-11T06:18:37.406Z","1.0.0":"2024-10-27T22:20:12.506Z","1.0.67":"2025-10-26T21:47:27.688Z","1.2.0":"2025-11-11T06:09:13.249Z","1.2.1":"2025-11-11T06:18:37.206Z"},"bugs":{"url":"https://github.com/bytarch/bytarch-node/issues"},"author":{"name":"BytArch","email":"bytarchbit@gmail.com"},"license":"ISC","homepage":"https://github.com/bytarch/bytarch-node#readme","keywords":["AI","bytarch"],"repository":{"type":"git","url":"git+https://github.com/bytarch/bytarch-node.git"},"description":"The official javascript library for the BytArch API","maintainers":[{"name":"bytarch","email":"bytarchbit@gmail.com"}],"readme":"\r\n# @bytarch/ai\r\n\r\nThe official javascript library for the BytArch API\r\n## Features\r\n\r\n- Fetch and display available AI models from the BytArch API.\r\n- Filter models to show only free models or Sky extension models.\r\n- Generate AI-powered chat completions and stream responses in real-time.\r\n- Upload files (images, documents) to the BytArch platform.\r\n- List uploaded media files.\r\n- Access public uploads, chats, and retrieve items by ID.\r\n- Simple and intuitive API for interacting with BytArch services.\r\n\r\n## Installation\r\n\r\nTo install @bytarch/ai, you can use npm:\r\n\r\n```bash\r\nnpm install @bytarch/ai\r\n```\r\n\r\n## Usage\r\n\r\nTo get started, you need to import the `BytArch` class and create an instance by providing your API key.\r\n\r\n```javascript\r\nimport { BytArch } from '@bytarch/ai';\r\n\r\nconst client = new BytArch({ apiKey: 'BytArch_API_KEY' });\r\n```\r\n## AI Chat Completions\r\n\r\nThe `BytArch` library provides access to AI-powered chat completions through an OpenAI-compatible interface.\r\n\r\n### Non-Streaming Chat Completion\r\n\r\n```javascript\r\nimport { BytArch } from '@bytarch/ai';\r\n\r\nconst client = new BytArch({ apiKey: 'BytArch_API_KEY' });\r\n\r\ntry {\r\n    const chatCompletion = await client.chat.completions.create({\r\n        messages: [{ role: 'user', content: 'Say this is a test' }],\r\n        model: \"phind-405b\",\r\n    });\r\n    console.log('Chat Completion:', chatCompletion.choices[0].message.content);\r\n} catch (error) {\r\n    console.error('Error fetching chat completion:', error);\r\n}\r\n```\r\n\r\n### Streaming Chat Completions\r\n\r\n```javascript\r\nimport { BytArch } from '@bytarch/ai';\r\n\r\nconst client = new BytArch({ apiKey: 'BytArch_API_KEY' });\r\n\r\ntry {\r\n    const stream = await client.chat.completions.create({\r\n        model: \"phind-405b\",\r\n        messages: [{ role: 'user', content: 'Say this is a test' }],\r\n        stream: true,\r\n    });\r\n\r\n    for await (const chunk of stream) {\r\n        process.stdout.write(chunk.choices[0]?.delta?.content || '');\r\n    }\r\n    console.log(); // Add newline after streaming\r\n} catch (error) {\r\n    console.error('Error streaming chat completion:', error);\r\n}\r\n```\r\n\r\n## Displaying Available Models\r\n\r\n```javascript\r\nimport { displayModels } from '@bytarch/ai';\r\n\r\nconsole.log(\"Fetching all models...\");\r\nconst allModels = await displayModels();\r\nconsole.log(`Total models: ${allModels?.data?.length || 0}`);\r\n\r\nconsole.log(\"\\nFetching free models only...\");\r\nconst freeModels = await displayModels({ free: true });\r\nconsole.log(`Free models: ${freeModels?.data?.length || 0}`);\r\n\r\nconsole.log(\"\\nFetching Sky models...\");\r\nconst skyModels = await displayModels({ sky: true });\r\nconsole.log(`Sky extension models: ${skyModels?.data?.length || 0}`);\r\n```\r\n\r\n## File Uploads\r\n\r\nUpload files to the BytArch platform:\r\n\r\n```javascript\r\nimport { BytArch } from '@bytarch/ai';\r\n\r\nconst client = new BytArch({ apiKey: 'BytArch_API_KEY' });\r\n\r\n// Upload a file from path\r\nconst uploadResult = await client.uploads.create('/path/to/your/file.jpg');\r\nconsole.log('Upload result:', uploadResult);\r\n\r\n// Upload a Buffer\r\nconst fs = await import('fs');\r\nconst fileBuffer = fs.readFileSync('/path/to/your/file.jpg');\r\nconst bufferUpload = await client.uploads.create(fileBuffer, { fileName: 'my-image.jpg' });\r\n\r\n// List uploaded files\r\nconst uploads = await client.uploads.list();\r\nconsole.log('Uploaded files:', uploads);\r\n```\r\n\r\n## Public API Access\r\n\r\nAccess public content without authentication:\r\n\r\n```javascript\r\nimport { BytArch } from '@bytarch/ai';\r\n\r\nconst publicClient = new BytArch().public; // No API key needed for public access\r\n\r\n// List public uploads\r\nconst publicUploads = await publicClient.listUploads();\r\nconsole.log('Public uploads:', publicUploads);\r\n\r\n// List public chats\r\nconst publicChats = await publicClient.listChats();\r\nconsole.log('Public chats:', publicChats);\r\n\r\n// Get specific item by ID\r\nconst item = await publicClient.getById('some-id');\r\nconsole.log('Public item:', item);\r\n```\r\n\r\n## Error Handling\r\n\r\nThe library throws errors when:\r\n- An invalid API key format is provided (must be valid UUID).\r\n- Network requests fail.\r\n- File uploads are invalid.\r\n\r\n## Available Scripts\r\n\r\nThe package.json includes several scripts for testing different functionalities:\r\n\r\n- `npm run models` - Test displaying available models\r\n- `npm run chat` - Test chat completion\r\n- `npm run stream` - Test streaming chat completion\r\n\r\n## Contributing\r\n\r\nContributions are welcome! If you would like to enhance this project, please submit issues or pull requests.\r\n\r\n## License\r\n\r\nThis project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.\r\n\r\n## Contact\r\n\r\nFor any questions or support, please reach out to the project maintainers.\r\n","readmeFilename":"README.md"}