generate_image
Generate an image using StableDiffusion 1.x models
SDK Method
async def generate_image(prompt, model, sampler, width=1024, height=1024, image_count=1,
negative_prompt="", cfg_scale=10, steps=30, loras={}, upscale=False) -> list[str]
Usage example
import aiohttp
from VisionCraftAPI import VisionCraftClient
async def main():
# Set your API key
api_key = "YOUR_API_KEY"
# Create a VisionCraftClient instance
client = VisionCraftClient(api_key=api_key)
# Generate an image with the SD 1.X model and sampler
images = await client.generate_image(
prompt='A beautiful sunset',
model='anything_V5',
sampler='Euler',
image_count=4
)
# Download and save the generated images
async with aiohttp.ClientSession() as session:
for i, image_url in enumerate(images):
async with session.get(image_url) as image_response:
image_data = await image_response.read()
# Save the image locally
with open(f"generated_image_{i}.png", "wb") as f:
f.write(image_data)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
For further information go to API Docs
Last updated