Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kabirjaipal/node-dall-ai
A type safe library for interacting with OpenAI's Dall-E 2 AI.
https://github.com/kabirjaipal/node-dall-ai
axios dall-e dall-e-api discord-bot discordjs image-processing imagegeneration nodejs openai-api
Last synced: 4 months ago
JSON representation
A type safe library for interacting with OpenAI's Dall-E 2 AI.
- Host: GitHub
- URL: https://github.com/kabirjaipal/node-dall-ai
- Owner: kabirjaipal
- License: mit
- Created: 2022-12-27T16:30:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-27T17:17:12.000Z (about 2 years ago)
- Last Synced: 2024-09-17T16:50:21.253Z (5 months ago)
- Topics: axios, dall-e, dall-e-api, discord-bot, discordjs, image-processing, imagegeneration, nodejs, openai-api
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-dall-ai-2
A type safe library for interacting with OpenAI's Dall-E 2 AI.
Dall-E 2 is a new AI system that can create realistic images and art from a description in natural langauge.
[https://openai.com/dall-e-2/](https://openai.com/dall-e-2/)
# Setup
To get access to Dall-E 2's API you need to join the waitlist and wait to be accepted which can be found [here](https://labs.openai.com/waitlist).
1. To get the your unique session key you need to go to [https://labs.openai.com/](https://labs.openai.com/).
2. Open the Network Tab in Developer Tools in your browser.
3. Send an image request in the input box.
4. In the network tab you'll find a POST request to [https://labs.openai.com/api/labs/tasks](https://labs.openai.com/api/labs/tasks).
5. In the POST request headers you'll find your session key in the "Authorization" header, it'll look something like "sess-xxxxxxxxxxxxxxxxxxxxxxxxxxxx".# Usage
```sh
npm i node-dall-ai-2
``````js
import { Dalle } from "node-dall-ai-2";const dalle = new Dalle({
apiKey: `Auth_Token`,
});(async () => {
const data = await dalle.generate(`cat`); // return array of dataconsole.log(data);
})();
```### Output
```
[
{
id: 'generation-QyXXdJP165TiSpSrzBqAo6IS',
object: 'generation',
created: 1659149946,
generation_type: 'ImageGeneration',
generation: {
image_path: 'https://openailabsprodscus.blob.core.windows.net/private/...'
},
task_id: 'task-QCKmkq8rxg0ablIgiXizTn0y',
prompt_id: 'prompt-IN4gE4yFBTi4MPlEG3GzCE4R',
is_public: false
},
{
id: 'generation-UNJiRu5dzbvJYo8FVnZs5SCS',
object: 'generation',
created: 1659149946,
generation_type: 'ImageGeneration',
generation: {
image_path: 'https://openailabsprodscus.blob.core.windows.net/private/...'
},
task_id: 'task-QCKmkq8rxg0ablIgiXizTn0y',
prompt_id: 'prompt-IN4gE4yFBTi4MPlEG3GzCE4R',
is_public: false
},
{
id: 'generation-XCqpvMF0araPjFczwwfDGHGv',
object: 'generation',
created: 1659149946,
generation_type: 'ImageGeneration',
generation: {
image_path: 'https://openailabsprodscus.blob.core.windows.net/private/...'
},
task_id: 'task-QCKmkq8rxg0ablIgiXizTn0y',
prompt_id: 'prompt-IN4gE4yFBTi4MPlEG3GzCE4R',
is_public: false
},
{
id: 'generation-sSo1TufL7d4OSGEBTwRTMtxv',
object: 'generation',
created: 1659149946,
generation_type: 'ImageGeneration',
generation: {
image_path: 'https://openailabsprodscus.blob.core.windows.net/private/...'
},
task_id: 'task-QCKmkq8rxg0ablIgiXizTn0y',
prompt_id: 'prompt-IN4gE4yFBTi4MPlEG3GzCE4R',
is_public: false
}
]
```### Get the first image URL
```js
const firstImage = data[0].generation.image_path;
console.log(firstImage);
```### Output
```
'https://openailabsprodscus.blob.core.windows.net/private/...'
```
# Support Server
[Join Now](https://discord.gg/PcUVWApWN3)
# Npm Package
[Visit](https://www.npmjs.com/package/node-dall-ai-2)
# Discord Bot Example
[Visit](https://github.com/kabirsingh2004/dall-e-discord-bot)
Thanks For Visiting Here