A client for the Creative Catalyst Engine API.
Project description
Creative Catalyst API Client
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.6
(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.
-
Configure
pip: Add the following line to the top of yourrequirements.txtfile, replacingYOUR-GITHUB-USERNAMEwith the correct GitHub organization or username:--extra-index-url https://pypi.pkg.github.com/YOUR-GITHUB-USERNAME -
Set Authentication Token: Before running
pip install, set your PAT as an environment variable:export GITHUB_TOKEN=your_personal_access_token_here
-
Install: Now,
pip install -r requirements.txtwill be able to find and download the package from the private registry.
Usage
Configuration
Ensure the following environment variable is set in the environment where you are running your application:
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.
The get_creative_report_stream method is a Python generator. You should iterate over it in a for loop to receive real-time status updates.
from api_client.client import CreativeCatalystClient
from api_client.exceptions import APIClientError
client = CreativeCatalystClient()
creative_brief = "A new creative brief..."
final_report = None
try:
# The new method is now iterable in a for loop.
for update in client.get_creative_report_stream(creative_brief):
event_type = update.get("event")
if event_type == "job_submitted":
print(f"Job successfully submitted with ID: {update.get('job_id')}")
elif event_type == "progress":
# This is a real-time progress update.
status_message = update.get("status")
print(f"Server progress: {status_message}")
elif event_type == "complete":
# This is the final, successful result.
final_report = update.get("result")
print("Successfully received the final report.")
break # Exit the loop
except APIClientError as e:
print(f"An error occurred: {e}")
# Now you can use the final report.
if final_report:
print("\n--- Final Report Theme ---")
print(final_report.get('final_report', {}).get('overarching_theme'))
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.
- Create a virtual environment:
python3 -m venv venv source venv/bin/activate
- Install all dependencies:
pip install -r dev-requirements.txt
- To add a dependency, edit
pyproject.toml(for production) ordev-requirements.in(for development). - To update the lock files, run:
pip-compile --strip-extras dev-requirements.in. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file creative_catalyst_client-1.1.6.tar.gz.
File metadata
- Download URL: creative_catalyst_client-1.1.6.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fd5b7f67c8e1b94c9f1a05a7e5232e63c193c72f84e0fba411302fec248ba69
|
|
| MD5 |
a1e9babb47b0ef2b25ae0f970dbf18a3
|
|
| BLAKE2b-256 |
988230f352ebbc6521b565a4766c988661b362953ecbfbdede8b53efaafb93e3
|
Provenance
The following attestation bundles were made for creative_catalyst_client-1.1.6.tar.gz:
Publisher:
publish.yml on MTawhid7/creative-catalyst-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
creative_catalyst_client-1.1.6.tar.gz -
Subject digest:
1fd5b7f67c8e1b94c9f1a05a7e5232e63c193c72f84e0fba411302fec248ba69 - Sigstore transparency entry: 538345008
- Sigstore integration time:
-
Permalink:
MTawhid7/creative-catalyst-client@a83f89d3e5f8653ad1e49c288e2c7e92cfef131b -
Branch / Tag:
refs/tags/v1.1.6 - Owner: https://github.com/MTawhid7
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a83f89d3e5f8653ad1e49c288e2c7e92cfef131b -
Trigger Event:
push
-
Statement type:
File details
Details for the file creative_catalyst_client-1.1.6-py3-none-any.whl.
File metadata
- Download URL: creative_catalyst_client-1.1.6-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c899ee9446d8e8546e19cf7092dcbc003f3e3ec15b4cba0378fd47b80efb55fc
|
|
| MD5 |
d027f949e5f4cb44814aaa6fd7b791ad
|
|
| BLAKE2b-256 |
639eb05bb556f41316a179b854d0218d7bee9254d691aaf5837b0cb8f2c1cdea
|
Provenance
The following attestation bundles were made for creative_catalyst_client-1.1.6-py3-none-any.whl:
Publisher:
publish.yml on MTawhid7/creative-catalyst-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
creative_catalyst_client-1.1.6-py3-none-any.whl -
Subject digest:
c899ee9446d8e8546e19cf7092dcbc003f3e3ec15b4cba0378fd47b80efb55fc - Sigstore transparency entry: 538345020
- Sigstore integration time:
-
Permalink:
MTawhid7/creative-catalyst-client@a83f89d3e5f8653ad1e49c288e2c7e92cfef131b -
Branch / Tag:
refs/tags/v1.1.6 - Owner: https://github.com/MTawhid7
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a83f89d3e5f8653ad1e49c288e2c7e92cfef131b -
Trigger Event:
push
-
Statement type: