Commit bcc54ea9

Christian Malpass <chriscellphonerepair@gmail.com>
2024-01-04 00:52:30
Add Picture API file example to the Examples Folder (#977)
* 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 <23kilpatrick23@gmail.com>
1 parent bba2343
Changed files (1)
examples
examples/picture.py
@@ -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()