Last active
March 18, 2026 21:07
-
-
Save lotharschulz/f41e2a8963189ff288470c7aa7c0ca79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openai import OpenAI | |
| import os | |
| from pathlib import Path | |
| # Ensure you have set your OpenAI API key in the environment variable 'openAI_API_Key' before running this code. | |
| api_key = os.getenv("openAI_API_Key") | |
| if not api_key: | |
| raise RuntimeError("Set the openAI_API_Key environment variable first.") | |
| client = OpenAI(api_key=api_key) | |
| models = ["gpt-5.4-mini", "gpt-5.4-nano"] | |
| prompts = [ | |
| "Generate a single HTML/CSS file that renders a functional, interactive 'Fidget Spinner' using only CSS animations. It should have three weighted arms, and the speed of rotation should increase if the user clicks a 'Spin' button.", | |
| "Write a 5-line poem about artificial intelligence. However, the first letter of each line must spell 'HORSE', and the last letter of each line must spell 'EARTH'.", | |
| ] | |
| output_dir = Path("outputs") | |
| output_dir.mkdir(exist_ok=True) | |
| for model in models: | |
| for i, prompt in enumerate(prompts): | |
| try: | |
| response = client.responses.create( | |
| model=model, | |
| input=prompt, | |
| max_output_tokens=7000, | |
| ) | |
| text = response.output_text | |
| print(f"\nModel: {model}\n") | |
| print(f"Prompt {i}: {prompt}\n") | |
| print(text) | |
| print("-" * 80) | |
| ext = "html" if i == 0 else "txt" | |
| out_file = output_dir / f"response_{model}_prompt_{i}.{ext}" | |
| with open(out_file, "w", encoding="utf-8") as f: | |
| f.write(text) | |
| except Exception as e: | |
| print(f"Error for model={model}, prompt={i}: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment