openai/openai-python
Publicmirrored fromhttps://github.com/openai/openai-pythonAvailable
examples/picture.py
21lines · modecode
| 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 | |
| 11 | |
| 12 | def main() -> None: |
| 13 | # Generate an image based on the prompt |
| 14 | response = openai.images.generate(prompt=prompt, model=model) |
| 15 | |
| 16 | # Prints response containing a URL link to image |
| 17 | print(response) |
| 18 | |
| 19 | |
| 20 | if __name__ == "__main__": |
| 21 | main() |
| 22 | |