PICTIFY
Python SDK

Python SDK
+ Pictify

Official Python library for data science and backend applications.

SDKs & Libraries

About Integration

The Pictify Python SDK enables image generation from Python applications, notebooks, and scripts. Perfect for data science workflows, Django/Flask backends, and automation scripts.

Key Capabilities

Async support

Type hints

Pandas integration

Jupyter-friendly

Common Use Cases

Django/Flask backends

Data visualization exports

Jupyter notebooks

Batch scripts

Integration Guide

5 minutes

Prerequisites

  • Python 3.8 or higher
  • A Pictify account with an API key
  • A template created in Pictify
1

Install the SDK

Install the Pictify package using pip.

Code
# Using pip
pip install pictify

# Using poetry
poetry add pictify

# Using pipenv
pipenv install pictify
2

Initialize the Client

Create a Pictify client with your API key. Use environment variables to keep credentials secure.

Code
import os
from pictify import Pictify

# Initialize with API key from environment
client = Pictify(api_key=os.environ.get('PICTIFY_API_KEY'))

# Or pass directly (not recommended for production)
client = Pictify(api_key='your-api-key')
!

Set your API key with: export PICTIFY_API_KEY=your-key

3

Generate an Image

Use the render method to generate images from your templates.

Code
result = client.render(
    template_id='your-template-id',
    variables={
        'title': 'Hello from Python',
        'subtitle': 'Generated with the Pictify SDK',
        'accent_color': '#667eea'
    },
    format='png',
    width=1200,
    height=630
)

print(f"Image URL: {result.image_url}")
# https://cdn.pictify.io/renders/abc123.png
4

Download Image Locally

Save the generated image to your local filesystem.

Code
# Download as bytes
image_bytes = client.render(
    template_id='your-template-id',
    variables={'title': 'Download Test'},
    download=True
)

# Save to file
with open('output.png', 'wb') as f:
    f.write(image_bytes)

# Or use the convenience method
client.render_to_file(
    template_id='your-template-id',
    variables={'title': 'Save Test'},
    output_path='my-image.png'
)
5

Batch Processing with Pandas

Generate images from a DataFrame—perfect for data science workflows.

Code
import pandas as pd

# Load your data
df = pd.read_csv('products.csv')

# Generate images for each row
results = client.render_batch(
    template_id='product-card-template',
    items=[
        {
            'variables': {
                'name': row['product_name'],
                'price': f"$" + "{row['price']:.2f}",
                'image': row['image_url']
            }
        }
        for _, row in df.iterrows()
    ]
)

# Add image URLs back to DataFrame
df['generated_image'] = [r.image_url for r in results]
df.to_csv('products_with_images.csv', index=False)
!

For large datasets, process in chunks to avoid memory issues.

6

Async Support

Use async/await for non-blocking image generation in async applications.

Code
import asyncio
from pictify import AsyncPictify

async def generate_images():
    client = AsyncPictify(api_key=os.environ.get('PICTIFY_API_KEY'))

    # Generate multiple images concurrently
    tasks = [
        client.render(
            template_id='your-template-id',
            variables={'title': f'Image {i}'}
        )
        for i in range(10)
    ]

    results = await asyncio.gather(*tasks)

    for i, result in enumerate(results):
        print(f"Image {i}: {result.image_url}")

    await client.close()

asyncio.run(generate_images())
!

Always close the async client when done to release connections.

7

Display in Jupyter Notebook

Display generated images directly in Jupyter notebooks.

Code
from IPython.display import Image, display

result = client.render(
    template_id='your-template-id',
    variables={'title': 'Notebook Demo'}
)

# Display from URL
display(Image(url=result.image_url))

# Or display from bytes
image_bytes = client.render(
    template_id='your-template-id',
    variables={'title': 'Direct Display'},
    download=True
)
display(Image(data=image_bytes))

Fast Install

$ pip install pictify

Ready to build with Python SDK?

Get your API key in seconds and start generating images programmatically.

Related Integrations