Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import requests | |
| API_ENDPOINT = "https://api.openai.com/v1/images/generations" | |
| st.title("Pixel Art Generator") | |
| st.write("Введите текст для генерации пиксельного искусства:") | |
| text_input = st.text_input("") | |
| if st.button("Создать пиксельный арт"): | |
| prompt = "pixel art " + text_input | |
| data = { | |
| "model": "image-alpha-001", | |
| "prompt": prompt, | |
| "num_images": 1, | |
| "size": "256x256", | |
| "response_format": "url" | |
| } | |
| headers = { | |
| "Content-Type": "application/json", | |
| "Authorization": "Bearer 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" | |
| } | |
| response = requests.post(url=API_ENDPOINT, json=data, headers=headers) | |
| if response.ok: | |
| st.write("Ваш пиксельный арт:") | |
| st.image(response.json()["data"][0]["url"], use_column_width=True) | |
| st.write("Powered By DALL•E 2") | |
| else: | |
| st.write("Ошибка при создании пиксельного искусства") | |