openai/openai-python

Public

mirrored fromhttps://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e41abf7b7dbc1e744d167f748e55d4dedfc0dca7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

examples/picture.py

21lines · modecode

1#!/usr/bin/env python
2
3from openai import OpenAI
4
5# gets OPENAI_API_KEY from your environment variables
6openai = OpenAI()
7
8prompt = "An astronaut lounging in a tropical resort in space, pixel art"
9model = "dall-e-3"
10
11
12def 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
20if __name__ == "__main__":
21 main()
22