Bleu AI Python SDK
A Python client library for interacting with Bleu AI workflows.
Installation
pip install bleuai
Quick Start
import asyncio
from bleuai import BleuAI
async def main():
# Initialize the client with your API key
client = BleuAI(api_key="your-api-key-here")
# Run a workflow and wait for completion
result = await client.run_workflow(
workflow_id="your-workflow-uuid",
inputs={
"prompt": "Generate an image of a sunset over mountains"
}
)
# Check if successful
if result.is_completed:
print("Workflow completed successfully!")
print(f"Outputs: {result.outputs}")
else:
print(f"Workflow failed: {result.error}")
# Close the client
await client.close()
# Run the async function
asyncio.run(main())
Example
See example.py for a complete working example:
export BLEU_API_KEY="your-api-key"
python example.py
Usage
Basic Usage
The SDK provides a simple interface to run Bleu AI workflows:
from bleuai import BleuAI
# Create client
client = BleuAI(api_key="your-api-key")
# Run workflow (async)
result = await client.run_workflow(
workflow_id="workflow-uuid",
inputs={"key": "value"}
)
Synchronous Usage
For non-async environments, use the synchronous wrapper:
from bleuai import BleuAI
client = BleuAI(api_key="your-api-key")
# This creates an event loop internally
result = client.run_workflow_sync(
workflow_id="workflow-uuid",
inputs={"key": "value"}
)
Context Manager
The client can be used as an async context manager:
async with BleuAI(api_key="your-api-key") as client:
result = await client.run_workflow(
workflow_id="workflow-uuid",
inputs={"prompt": "Hello, world!"}
)
Handling Results
The WorkflowResult object provides convenient access to outputs:
result = await client.run_workflow(workflow_id="...", inputs={...})
# Check status
if result.is_completed:
# Get all outputs
all_outputs = result.outputs
# Get output from specific node
node_output = result.get_output(node_id="node-123")
# Get outputs by type
images = result.get_output(output_type="image")
elif result.is_failed:
print(f"Error: {result.error}")
Error Handling
The SDK provides specific exception types for different error scenarios:
from bleuai import (
BleuAI,
AuthenticationError,
WorkflowNotFoundError,
InsufficientCreditsError,
WorkflowExecutionError
)
try:
client = BleuAI(api_key="your-api-key")
result = await client.run_workflow(
workflow_id="workflow-uuid",
inputs={"prompt": "Generate something"}
)
except AuthenticationError:
print("Invalid API key")
except WorkflowNotFoundError:
print("Workflow not found or no access")
except InsufficientCreditsError:
print("Not enough credits to run workflow")
except WorkflowExecutionError as e:
print(f"Workflow execution failed: {e}")
Timeout Configuration
You can configure the timeout for workflow execution:
# Wait up to 10 minutes for completion
result = await client.run_workflow(
workflow_id="workflow-uuid",
inputs={...},
timeout=600.0 # seconds
)
Fire and Forget
To start a workflow without waiting for completion:
# Start workflow and return immediately
result = await client.run_workflow(
workflow_id="workflow-uuid",
inputs={...},
wait_for_completion=False
)
print(f"Workflow started with job ID: {result.job_id}")
API Reference
BleuAI
Main client class for interacting with Bleu AI.
Constructor
BleuAI(
api_key: str,
base_url: str = "https://api.buildbleu.com",
supabase_url: str = "...",
supabase_anon_key: str = "..."
)
Methods
async run_workflow(workflow_id, inputs, wait_for_completion, timeout)- Run a workflowrun_workflow_sync(workflow_id, inputs, timeout)- Synchronous workflow executionasync close()- Close the client connection
WorkflowResult
Result object returned from workflow execution.
Attributes
job_id: str- Unique job identifierstatus: WorkflowStatus- Current status (PENDING, RUNNING, COMPLETED, FAILED)outputs: Optional[Dict]- Workflow outputs (when completed)error: Optional[str]- Error message (when failed)
Methods
is_completed: bool- Check if workflow completed successfullyis_failed: bool- Check if workflow failedget_output(node_id, output_type)- Get specific outputs
Requirements
- Python 3.7+
- httpx
- supabase
- realtime
License
MIT
Support
For support, please contact contact@buildbleu.com or visit https://buildbleu.com
Metadata
Release files for bleuai 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bleuai-0.3.0.tar.gz | 11.3 kB | Without provenance | Details for bleuai-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bleuai-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for bleuai-0.3.0-py3-none-any.whl |
Total release size: 21.0 kB
Release files / bleuai-0.3.0.tar.gz
| Download URL | bleuai-0.3.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9d8c305bf358f6db830973052f31b5c39c0df3e3833732cbd71a3e9f30b4207
|
|
BLAKE2b-256 checksum How to use checksums |
ff6f6f5c212f6dcff53c0b37060476bfb108c380a9633c0ddcd5d41a983407f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / bleuai-0.3.0-py3-none-any.whl
| Download URL | bleuai-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9385d020dc0ccbc0fe6c28cfbd61fcdcaf405a84cf4ecc3590e3355bd1bd3adb
|
|
BLAKE2b-256 checksum How to use checksums |
0d8d55427ece26c2c8233a912e108ec9d005a2aa163e5e346d9fa2386ea4b10d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for bleuai 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.