|
| 1 | +# Dalle |
| 2 | + |
| 3 | +This script utilizes the OpenAI API to generate an image based on a given prompt using the DALL-E model. |
| 4 | + |
| 5 | +## Setup instructions |
| 6 | + |
| 7 | +To set up and run the script, follow the instructions below: |
| 8 | + |
| 9 | +1. Install the required dependencies: |
| 10 | + - `requests` |
| 11 | + - `openai` (Install using `pip install openai`) |
| 12 | + |
| 13 | +2. Obtain an API key from OpenAI: |
| 14 | + - Sign up for an account at [OpenAI](https://www.openai.com/). |
| 15 | + - Generate an API key. |
| 16 | + |
| 17 | +3. Set the API key: |
| 18 | + - Replace `"your-api-key"` in the script with your actual API key obtained from OpenAI. |
| 19 | + |
| 20 | +4. Run the script: |
| 21 | + - Execute the script using a Python interpreter. |
| 22 | + - Enter a prompt when prompted by the script. |
| 23 | + |
| 24 | +## Detailed explanation of script |
| 25 | + |
| 26 | +The script performs the following steps: |
| 27 | + |
| 28 | +1. Imports the necessary libraries (`requests` and `openai`). |
| 29 | +2. Sets up the OpenAI API client using the API key. |
| 30 | +3. Defines the DALL-E model engine and the prompt (message) provided by the user. |
| 31 | +4. Generates a response by calling the OpenAI API and passing the prompt. |
| 32 | +5. Retrieves the URL of the generated image from the response. |
| 33 | +6. Downloads the image using the URL and saves it as "image.jpg". |
| 34 | +7. Prints the generated image URL. |
| 35 | + |
| 36 | +## Output |
| 37 | + |
| 38 | +The script saves the generated image as "image.jpg" in the current directory. The URL of the generated image is also printed to the console. |
| 39 | + |
| 40 | +## Author(s) |
| 41 | + |
| 42 | +Author: [Mihir Panchal](https://github.com/MihirRajeshPanchal) |
| 43 | + |
| 44 | +## Disclaimers, if any |
| 45 | + |
| 46 | +No specific disclaimers or legal information apply to this script. |
0 commit comments