├── .gitignore ├── LICENSE ├── README.md ├── index.html └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | api.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Saurav Hathi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Image Generator using OpenAI API 2 | 3 | This is a simple image generator using [OpenAI API](https://openai.com/api/). you can generate images by entering short description of the image or by entering a keyword. 4 | 5 | ## Demo 6 | 7 | ### [https://sauravhathi.github.io/image-generator-using-openai-api/](https://sauravhathi.github.io/image-generator-using-openai-api/) 8 | 9 | ![image](https://user-images.githubusercontent.com/61316762/202867475-5f95d9f8-882b-411c-af58-1a4406fe4012.png) 10 | ### images generated by AI 11 | ![image](https://user-images.githubusercontent.com/61316762/202867487-65e9fda0-f24d-46e8-b95e-4f6b4cc29199.png) 12 | 13 | ![image](https://user-images.githubusercontent.com/61316762/202919273-86aa69e3-0a09-4161-bf31-a011ae0306a4.png) 14 | 15 | ![image](https://user-images.githubusercontent.com/61316762/202919277-94c5f69e-cce1-470f-ac00-ff29db71d6dc.png) 16 | 17 | ## How to use 18 | 19 | - Enter your OpenAI API key 20 | - Enter a short description of the image or a keyword 21 | - Select image size 22 | - Select number of images 23 | - Click on generate button 24 | - Double click on the image to download it 25 | 26 | ## API Reference 27 | 28 | [OpenAI API](https://openai.com/api/) 29 | 30 | `Note:` Sign up for an API key and add it to the `api.js` file 31 | 32 | ## Run Locally 33 | 34 | Clone the project 35 | 36 | ```bash 37 | git clone https://github.com/sauravhathi/image-generator-using-openai-api 38 | ``` 39 | 40 | Go to the project directory 41 | 42 | 1. Create api.js file in the root directory and add your API key 43 | 44 | ```javascript 45 | const api = "YOUR_API_KEY"; 46 | ``` 47 | 48 | ```bash 49 | cd image-generator-openai 50 | ``` 51 | 52 | Open `index.html` in your browser 53 | 54 | ## Authors 55 | 56 | - [@sauravhathi](https://www.github.com/sauravhathi) 57 | 58 | ## License 59 | 60 | [MIT](https://github.com/sauravhathi/image-generator-using-openai-api/blob/master/LICENSE) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Image Gererator using OpenAI API 13 | 14 | 15 | 16 |
17 |
18 |

Image Generator

19 |

20 | This is a simple image generator using 21 | OpenAI API. 22 | You can generate images by entering a short description of the image or by entering a keyword. 23 |

24 |
25 |
26 |
27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 | 49 |
50 |
51 |
52 | 58 | 59 | 60 | 199 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .input-style { 2 | border: 2px solid #ccc; 3 | border-radius: 0.25rem; 4 | padding: 0.5rem; 5 | color: #666; 6 | background-color: #fff; 7 | width: 100%; 8 | outline: none; 9 | } 10 | 11 | .button-style { 12 | background-color: #eee; 13 | color: #111; 14 | font-weight: bold; 15 | padding: 0.5rem 1rem; 16 | border-radius: 0.25rem; 17 | outline: none; 18 | transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease; 19 | } 20 | 21 | .button-style:hover { 22 | background-color: #111; 23 | color: #fff; 24 | transform: translateY(-1px); 25 | } 26 | 27 | .button-style:focus { 28 | outline: none; 29 | } --------------------------------------------------------------------------------