File size: 470 Bytes
6bcddd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
from pathlib import Path


def generate_character_image(prompt: str, output_path: str | Path) -> Path | None:
    url = os.environ.get("VC_MODAL_IMAGE_URL")
    if not url:
        return None

    import httpx

    response = httpx.post(url, json={"prompt": prompt, "steps": 4}, timeout=240)
    response.raise_for_status()
    path = Path(output_path)
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_bytes(response.content)
    return path