Quick start
First of all, install the SDK via PyPl
pip install VisionCraftAPI
Secondly, create a VisionCraft client
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)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
Now you can use all methods, woo-hoo! Generate your first image!
import asyncio
from VisionCraftAPI import VisionCraftClient
async def generate_xl_image(client: VisionCraftClient,
prompt: str,
model: str,
sampler: str) -> bytes:
images = await client.generate_xl_image(
prompt=prompt,
model=model,
sampler=sampler
)
print('Image generated! Saving to image.png...')
with open('image.png', 'wb') as file:
file.write(images)
async def main():
# Set your API key
api_key = "YOUR_API_KEY"
# Create a VisionCraftClient instance
client = VisionCraftClient(api_key=api_key)
# Get all SDXL models and samplers
models = await client.get_xl_models()
samplers = await client.get_xl_samplers()
# Generate an image with the first model and sampler
await generate_xl_image(client=client,
prompt='A beautiful sunset',
model=models[0],
sampler=samplers[0])
if __name__ == '__main__':
asyncio.run(main())
Last updated