| import requests | |
| from io import BytesIO | |
| from PIL import Image | |
| import random | |
| def test_pollinations(prompt, model='flux'): | |
| print(f"🎨 Testing Pollinations with model='{model}'...") | |
| seed = random.randint(0, 100000) | |
| # Pollinations URL format: https://image.pollinations.ai/prompt/{prompt} | |
| # We must URL encode the prompt | |
| import urllib.parse | |
| encoded_prompt = urllib.parse.quote(prompt) | |
| url = f"https://image.pollinations.ai/prompt/{encoded_prompt}?nologo=true" | |
| print(f"Requesting: {url}") | |
| try: | |
| response = requests.get(url, timeout=30) | |
| if response.status_code == 200: | |
| img = Image.open(BytesIO(response.content)) | |
| filename = f"pollinations_simple.png" | |
| img.save(filename) | |
| print(f"✅ SUCCESS! Saved {filename}") | |
| else: | |
| print(f"❌ FAILED: {response.status_code} - {response.text}") | |
| except Exception as e: | |
| print(f"❌ ERROR: {e}") | |
| if __name__ == "__main__": | |
| test_pollinations("roman mercenaries, digital art") | |