https://github.com/aasif-iqbal/openai-image-generation-nodejs
Convert Text(prompt) into Image using OpenAI-DALL-E-3
https://github.com/aasif-iqbal/openai-image-generation-nodejs
dalle-3 express nodejs nodemon openai
Last synced: about 2 months ago
JSON representation
Convert Text(prompt) into Image using OpenAI-DALL-E-3
- Host: GitHub
- URL: https://github.com/aasif-iqbal/openai-image-generation-nodejs
- Owner: aasif-iqbal
- Created: 2024-04-15T15:54:03.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-14T19:17:40.000Z (12 months ago)
- Last Synced: 2025-01-18T09:34:18.201Z (3 months ago)
- Topics: dalle-3, express, nodejs, nodemon, openai
- Language: JavaScript
- Homepage:
- Size: 1.72 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAI-Image-Generation-NodeJs
## How to Create
1. Create an Account on Open Ai - [Click here](https://openai.com/)
2. Create Secret API Key - [Click here to create api-key](https://platform.openai.com/api-keys)
### How to Generate Image using OpenAI
Documentation: [Image Generation Doc](https://platform.openai.com/docs/guides/images?lang=node.js&adobe_mc=MCMID%3D60047592739492077280307194424969051085%7CMCORGID%3DA8833BC75245AF9E0A490D4D%2540AdobeOrg%7CTS%3D1701353004&context=node)The Images API provides three methods for interacting with images:
1. Creating images from scratch based on a text prompt (DALL·E 3 and DALL·E 2)
2. Creating edited versions of images by having the model replace some areas of a pre-existing image, based on a new text prompt (DALL·E 2 only)
3. Creating variations of an existing image (DALL·E 2 only)We are here, Using First method to create image from text prompt.
- We are using dall-e-3 here
```js
const generateImage = async function(req, res){const prompt = req.body.prompt;
try{
const response = await openai.images.generate({
model:'dall-e-3',
prompt:prompt,
n:1,
size:"1024x1024"
});
image_url = response.data.data[0].url;
res.send(image_url);
}catch(err){
res.send(err);
}
}
``````
#
Method: POSTUrl: https://api.openai.com/v1/images/generations
response-body
```json
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
```### Image Model - Price
