openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.13.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/picture.py

21lines · modeblame

bcc54ea9Christian Malpass2 years ago1#!/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
6f1adfecStainless Bot2 years ago11
bcc54ea9Christian Malpass2 years ago12def main() -> None:
13# Generate an image based on the prompt
14response = openai.images.generate(prompt=prompt, model=model)
6f1adfecStainless Bot2 years ago15
bcc54ea9Christian Malpass2 years ago16# Prints response containing a URL link to image
17print(response)
6f1adfecStainless Bot2 years ago18
19
bcc54ea9Christian Malpass2 years ago20if __name__ == "__main__":
21main()