Official Python SDK for the CronGateway AI Platform
Project description
CronGateway Python SDK
Official Python client for the CronGateway AI Platform.
Installation
pip install crongateway
Quick Start
from crongateway import CronGatewayClient
# Initialize the client
client = CronGatewayClient(api_key="your-api-key")
# Create a job
job = client.create_job(
tool_id="flux-pro",
input={
"prompt": "A beautiful sunset over mountains",
"aspect_ratio": "16:9"
}
)
# Check job status
status = client.get_job(job["id"])
print(f"Job status: {status['status']}")
# List all available models
tools = client.list_tools()
for tool in tools:
print(f"{tool['name']}: ${tool['costPerRun']} per run")
API Reference
Jobs
create_job(tool_id: str, input: dict) -> dict
Create a new AI job.
get_job(job_id: str) -> dict
Get job details by ID.
list_jobs() -> list
List all jobs for the authenticated user.
Tools
list_tools() -> list
List all available AI models/tools.
get_tool(tool_id: str) -> dict
Get a specific tool by ID.
search_tools(query: str) -> list
Search tools by name or description.
get_tools_by_category(category: str) -> list
Get tools filtered by category (Text, Image, Video, Audio).
Storage
list_artifacts() -> list
List all generated artifacts.
upload_file(file_path: str) -> dict
Upload a file to CronGateway storage.
Billing
top_up(amount: float) -> dict
Add credits to your account.
get_billing_history() -> list
Get billing transaction history.
get_usage_stats() -> dict
Get usage analytics and statistics.
Examples
Image Generation
client = CronGatewayClient(api_key="your-api-key")
# Generate an image with FLUX Pro
job = client.create_job(
tool_id="flux-pro",
input={
"prompt": "A futuristic cityscape at night, neon lights",
"aspect_ratio": "16:9"
}
)
# Poll for completion
import time
while True:
status = client.get_job(job["id"])
if status["status"] == "COMPLETED":
print(f"Image URL: {status['output']['image_url']}")
break
elif status["status"] == "FAILED":
print(f"Job failed: {status.get('error')}")
break
time.sleep(2)
Text Generation
client = CronGatewayClient(api_key="your-api-key")
# Generate text with Gemini
job = client.create_job(
tool_id="gemini-2.5-flash-preview",
input={
"prompt": "Explain quantum computing in simple terms"
}
)
status = client.get_job(job["id"])
if status["status"] == "COMPLETED":
print(status["output"]["text"])
Virtual Try-On (Cron TRY-ON)
client = CronGatewayClient(api_key="your-api-key")
# CronGateway's proprietary virtual try-on model
job = client.create_job(
tool_id="cron-try-on",
input={
"type": "clothing",
"image1": "https://example.com/person.jpg",
"image2": "https://example.com/shirt.jpg",
"prompt": "Make sure the shirt fits naturally"
}
)
status = client.get_job(job["id"])
if status["status"] == "COMPLETED":
print(f"Try-on result: {status['output']['image_url']}")
Error Handling
from crongateway import CronGatewayClient
import requests
client = CronGatewayClient(api_key="your-api-key")
try:
job = client.create_job("flux-pro", {"prompt": "test"})
except requests.exceptions.HTTPError as e:
if e.response.status_code == 401:
print("Invalid API key")
elif e.response.status_code == 402:
print("Insufficient credits")
else:
print(f"Error: {e}")
License
MIT
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 crongateway-0.1.0.tar.gz.
File metadata
- Download URL: crongateway-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd73aea16a54b3af08fd99934ff2e4408f478737ae6a9b940e78ccea6ab1598e
|
|
| MD5 |
aabfa95c05739753a641d2798b5a41d0
|
|
| BLAKE2b-256 |
52c91add9f93c2d782c74e8d5d482e013eb4f50f0216ea833d629dc19a63a94c
|
File details
Details for the file crongateway-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crongateway-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
415932e854d089b5257bbfea4b2a8cdc38b69eb9457ab0bcf5c72a966a7a65b0
|
|
| MD5 |
f05ef32e382122bb8502686aa1f18bf1
|
|
| BLAKE2b-256 |
2da707f73f2be4ec0e77101b6dad10bd603eb1bde5d11b31c5d34ae76856b046
|