Overview: Use OpenAI’s API to create AI-generated visuals.
Use Case: Visual content creation, AI art, or demo posters for training.
Install:
pip install openai
Working Code:
import openai
openai.api_key = 'your_api_key_here'
response = openai.Image.create(
prompt="a robot teaching kids about AI",
n=1,
size="512x512"
)
image_url = response['data'][0]['url']
print(image_url)
Note: Requires OpenAI API key — get it free at platform.openai.com