import requests
import json

def generate_image_with_sdxl(prompt, negative_prompt):
    """
    调用本地或云端SDXL API生成高分辨率国潮概念图
    """
    API_URL = "http://127.0.0.1:7860/sdxl/generate"
    headers = {
        "Content-Type": "application/json",
        "Authorization": "Bearer your_api_key"
    }
    # 这里的prompt融合了商业关键词与AI提示词
    payload = {
        "prompt": f"{prompt}, 潮汕英歌舞, 3d翻糖, 极其精致的奶油质感, 商业摄影, 8k分辨率",
        "negative_prompt": negative_prompt,
        "model": "sdxl-base-1.0",
        "width": 1024,
        "height": 1024
    }
    
    response = requests.post(API_URL, headers=headers, data=json.dumps(payload))
    if response.status_code == 200:
        result = response.json()
        print("图片生成成功,图片路径:", result['image_path'])
    else:
        print("API调用失败,状态码:", response.status_code)

# 测试运行
if __name__ == "__main__":
    p = "A cute 3d lion dance mascot on top of a blue ocean wave cream cake"
    n = "blur, low quality, deformed"
    generate_image_with_sdxl(p, n)
 

 

更多推荐