Working with Generative Models
Generate images, audio, 3D models, and video through ColabHive's policy-governed CPU and GPU execution layer.
Overview
ColabHive supports generative AI models from HuggingFace across four modalities:
| Modality | Task Types | Example Models |
|---|---|---|
| Image | text-to-image, image-to-image | Stable Diffusion XL, FLUX, SD3 |
| Audio | text-to-audio, text-to-speech | MusicGen, Bark, Parler TTS |
| 3D | image-to-3d, text-to-3d | Hunyuan3D 2.1, TripoSR |
| Video | text-to-video, image-to-video | CogVideoX, Stable Video Diffusion |
Step 1: Import a Model from HuggingFace
import colabhive
client = colabhive.Client(api_key="hive_...", account_id="...")
# Search for models
models = client.models.hf.search(query="stable-diffusion-xl", task_type="text-to-image")
for m in models:
print(f"{m['repo_id']} — {m.get('task_type', 'unknown')}")
# Register one
result = client.models.hf.register(repo_id="stabilityai/stable-diffusion-xl-base-1.0")
print(f"Endpoint created: {result['endpoint_id']}")
Or via the Console UI: Builder > Models > Discover > search > Register.
Step 2: Run Inference
Text-to-Image
result = client.endpoints.infer("your-endpoint-id", {
"prompt": "A cat wearing sunglasses on a beach, digital art",
"width": 1024,
"height": 1024,
"num_inference_steps": 30
})
# Download the generated image
for artifact in result["result"]["output_artifacts"]:
client.endpoints.download_artifact(artifact["url"], f"./{artifact['filename']}")
With Binary Input (Image-to-3D)
For tasks that require an input file (image, audio), upload it first:
# 1. Upload the input image
image_url = client.endpoints.upload_input("hunyuan3d-endpoint", "./chair_photo.png")
# 2. Use the URL in inference
result = client.endpoints.infer("hunyuan3d-endpoint", {
"image_url": image_url,
"format": "glb"
})
# 3. Download the 3D model
for artifact in result["result"]["output_artifacts"]:
if artifact["modality"] == "3d":
client.endpoints.download_artifact(artifact["url"], "./model.glb")
Via cURL
# Upload input
curl -X POST https://api.colabhive.com/api/builder/v1/endpoints/{id}/upload-input \
-H "X-API-Key: hive_..." -H "X-Account-ID: ..." \
-F "file=@./photo.png"
# Returns: {"input_url": "https://...", "expires_in": 3600}
# Run inference
curl -X POST https://api.colabhive.com/api/builder/v1/endpoints/{id}/infer \
-H "X-API-Key: hive_..." -H "X-Account-ID: ..." \
-H "Content-Type: application/json" \
-d '{"input": {"image_url": "THE_INPUT_URL", "format": "glb"}}'
Step 3: View Results
In the Console
The ColabHive Console renders results automatically:
- Images: Inline preview with download button
- Audio: Built-in audio player
- 3D models: Interactive 3D viewer (rotate, zoom) powered by model-viewer
- Video: Inline video player
Programmatically
result = client.endpoints.get_task(task_id)
if result["status"] == "succeeded":
for artifact in result["result"]["output_artifacts"]:
print(f"{artifact['modality']}: {artifact['filename']} ({artifact['size_bytes']} bytes)")
print(f" Download: {artifact['url']}")
Binary Input & Output Flow
┌──────────┐ upload_input() ┌─────────┐ infer() ┌──────────┐
│ Client │ ──────────────────► │ MinIO │ ◄──────────── │ Node │
│ (image) │ │ (S3) │ │ (GPU) │
└──────────┘ └─────────┘ └──────────┘
│ │
│ download input │
│◄────────────────────────│
│ │
│ upload output │
│◄────────────────────────│
│ │
┌──────────┐ download_artifact() │ │
│ Client │ ◄──────────────────────│ │
│ (.glb) │ │ │
└──────────┘ └─────────────────────────┘
Fine-Tuning Generative Models
LoRA Fine-Tuning (Recommended)
Train a lightweight adapter on your own images:
- Upload a dataset of images (ZIP file via Builder > Datasets > Upload)
- Create a training run with
training_type: "lora"and base model (e.g., SDXL) - After training, register the LoRA adapter as an inference endpoint
- Invoke with your custom style
DreamBooth Personalization
Teach a model a new concept (person, object, style) from 5-15 images:
- Upload images of your subject
- Set
training_type: "dreambooth"with aninstance_prompt(e.g., "a photo of sks dog") - Train for 500-1000 steps
- Generate new images of your subject in any context
Pricing
Generative tasks are priced by GPU time and output size (not tokens):
| Task Type | Rate (HC/GPU-sec) | Typical Cost |
|---|---|---|
| text-to-image | 0.002 | ~0.03 HC per image |
| image-to-3d | 0.003 | ~0.36 HC per 3D model |
| text-to-audio | 0.002 | ~0.04 HC per 10s clip |
| text-to-speech | 0.001 | ~0.005 HC per utterance |
| text-to-video | 0.005 | ~0.30 HC per 5s video |