Skip to content

Commit

Permalink
Add Picture API file example to the Examples Folder (#977)
Browse files Browse the repository at this point in the history
* Added a file to the examples folder to provide a simple example of retrieving and printing a picture to the console using the new API. Previously, no examples were provided for images, making it unclear.

* Update picture.py

---------

Co-authored-by: Logan Kilpatrick <[email protected]>
  • Loading branch information
furofo and logankilpatrick authored Jan 3, 2024
1 parent d828527 commit b201083
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/picture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

from openai import OpenAI

# gets OPENAI_API_KEY from your environment variables
openai = OpenAI()

prompt = "An astronaut lounging in a tropical resort in space, pixel art"
model = "dall-e-3"

def main() -> None:
# Generate an image based on the prompt
response = openai.images.generate(prompt=prompt, model=model)

# Prints response containing a URL link to image
print(response)

if __name__ == "__main__":
main()

0 comments on commit b201083

Please sign in to comment.