openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
examples/picture.py
21lines · modeblame
bcc54ea9Christian Malpass2 years ago | 1 | #!/usr/bin/env python |
| 2 | | |
| 3 | from openai import OpenAI | |
| 4 | | |
| 5 | # gets OPENAI_API_KEY from your environment variables | |
| 6 | openai = OpenAI() | |
| 7 | | |
| 8 | prompt = "An astronaut lounging in a tropical resort in space, pixel art" | |
| 9 | model = "dall-e-3" | |
| 10 | | |
6f1adfecStainless Bot2 years ago | 11 | |
bcc54ea9Christian Malpass2 years ago | 12 | def main() -> None: |
| 13 | # Generate an image based on the prompt | |
| 14 | response = openai.images.generate(prompt=prompt, model=model) | |
6f1adfecStainless Bot2 years ago | 15 | |
bcc54ea9Christian Malpass2 years ago | 16 | # Prints response containing a URL link to image |
| 17 | print(response) | |
6f1adfecStainless Bot2 years ago | 18 | |
| 19 | | |
bcc54ea9Christian Malpass2 years ago | 20 | if __name__ == "__main__": |
| 21 | main() |