Skip to main content

A client for the Creative Catalyst Engine API.

Project description

Creative Catalyst API Client

PyPI version License: MIT Python Versions

A robust Python client for interacting with the Creative Catalyst Engine API. This client handles job submission and uses a real-time Server-Sent Events (SSE) stream to provide progress updates and retrieve final results, eliminating the need for inefficient polling.


Table of Contents


Features

  • Simple Interface: A clean, intuitive client for submitting creative briefs.
  • Real-Time & Efficient: Uses Server-Sent Events (SSE) to get job status updates the moment they happen, with no need for manual polling.
  • Robust Error Handling: Includes a set of custom exceptions to handle API connection issues, job submission failures, and failed jobs gracefully.
  • Configurable: The target API server URL is configured via a single environment variable, making it easy to switch between development, staging, and production environments.

Installation

The package is hosted on the public Python Package Index (PyPI).

pip install creative-catalyst-client

It is highly recommended to pin the package to a specific version in your project's requirements.txt file to ensure reproducible builds:

# In your requirements.txt
creative-catalyst-client==1.1.1
(Alternative) Installation from Private GitHub Packages

If your project requires installing from the private GitHub Packages registry, you will need a GitHub Personal Access Token (PAT) with read:packages scope.

  1. Configure pip: Add the following line to the top of your requirements.txt file, replacing YOUR-GITHUB-USERNAME with the correct GitHub organization or username:

    --extra-index-url https://pypi.pkg.github.com/YOUR-GITHUB-USERNAME
    
  2. Set Authentication Token: Before running pip install, set your PAT as an environment variable:

    export GITHUB_TOKEN=your_personal_access_token_here
    
  3. Install: Now, pip install -r requirements.txt will be able to find and download the package from the private registry.


Usage

Configuration

The client is configured to find the server using a single environment variable. Before running your application, ensure the following variable is set:

CREATIVE_CATALYST_API_URL="http://<ip_address_of_catalyst_server>:9500"

The client will automatically read this value.

Example

The following is a complete example of how to submit a job and receive the final report.

import os
from api_client.client import CreativeCatalystClient
from api_client.exceptions import APIClientError

# Ensure the environment variable is set for the script to use.
# In a real application, this would be managed by your deployment environment.
os.environ["CREATIVE_CATALYST_API_URL"] = "http://127.0.0.1:9500"

# 1. Initialize the client. It automatically finds the URL from the environment.
client = CreativeCatalystClient()

# 2. Define your creative brief.
creative_brief = """
A collection of luxury silk scarves inspired by the art of Japanese kintsugi and the nebulae photographed by the James Webb Space Telescope.
"""

try:
    # 3. Submit the job and get the final report.
    # The client will print real-time progress updates to the console.
    final_report = client.get_creative_report(creative_brief)

    print("\n--- ✅ Final Report Received ---")
    if final_report.get("final_report"):
        print(f"Theme: {final_report['final_report'].get('overarching_theme')}")

except APIClientError as e:
    print(f"\n--- ❌ An Error Occurred ---")
    print(f"Error: {e}")

Error Handling

The client will raise specific exceptions for different failure modes, all inheriting from APIClientError. You can catch these to handle errors gracefully.

  • ConnectionError: Raised if the client cannot connect to the API server at all.
  • JobSubmissionError: Raised if the initial job submission fails (e.g., due to a server error or invalid request).
  • JobFailedError: Raised if the job is accepted but fails during processing on the worker.

Development

This section is for developers contributing to the creative-catalyst-client package itself.

The project uses pip-tools for dependency management.

  1. Create a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
    
  2. Install all dependencies:
    pip install -r dev-requirements.txt
    
  3. To add a dependency, edit pyproject.toml (for production) or dev-requirements.in (for development).
  4. To update the lock files, run: pip-compile --strip-extras dev-requirements.in.
  5. To build the package, run: python -m build.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

creative_catalyst_client-1.1.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

creative_catalyst_client-1.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file creative_catalyst_client-1.1.2.tar.gz.

File metadata

  • Download URL: creative_catalyst_client-1.1.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for creative_catalyst_client-1.1.2.tar.gz
Algorithm Hash digest
SHA256 d1400ab063d420f5467c850507f2ebaee2e5a59dda91750b45a9896cec0c2883
MD5 50d36ebca2035abaedfa6f2ab498e0dd
BLAKE2b-256 270102df4c1234f6cdb2c7b905f0c67583b318f88d0b8d2ed43281a71c2b9533

See more details on using hashes here.

Provenance

The following attestation bundles were made for creative_catalyst_client-1.1.2.tar.gz:

Publisher: publish.yml on MTawhid7/creative-catalyst-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file creative_catalyst_client-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for creative_catalyst_client-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 371d8d9246166928d7897718746a21333bcd8702c85f5fa961d20f884ea306cb
MD5 7d7713909631561e46c29893911168ba
BLAKE2b-256 a9f1dea246b0be6788a8ac0b7aa906ee5286bcaeaf618bf87a70a32fea373977

See more details on using hashes here.

Provenance

The following attestation bundles were made for creative_catalyst_client-1.1.2-py3-none-any.whl:

Publisher: publish.yml on MTawhid7/creative-catalyst-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page