Skip to main content

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:

ModalityTask TypesExample Models
Imagetext-to-image, image-to-imageStable Diffusion XL, FLUX, SD3
Audiotext-to-audio, text-to-speechMusicGen, Bark, Parler TTS
3Dimage-to-3d, text-to-3dHunyuan3D 2.1, TripoSR
Videotext-to-video, image-to-videoCogVideoX, 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

Train a lightweight adapter on your own images:

  1. Upload a dataset of images (ZIP file via Builder > Datasets > Upload)
  2. Create a training run with training_type: "lora" and base model (e.g., SDXL)
  3. After training, register the LoRA adapter as an inference endpoint
  4. Invoke with your custom style

DreamBooth Personalization

Teach a model a new concept (person, object, style) from 5-15 images:

  1. Upload images of your subject
  2. Set training_type: "dreambooth" with an instance_prompt (e.g., "a photo of sks dog")
  3. Train for 500-1000 steps
  4. Generate new images of your subject in any context

Pricing

Generative tasks are priced by GPU time and output size (not tokens):

Task TypeRate (HC/GPU-sec)Typical Cost
text-to-image0.002~0.03 HC per image
image-to-3d0.003~0.36 HC per 3D model
text-to-audio0.002~0.04 HC per 10s clip
text-to-speech0.001~0.005 HC per utterance
text-to-video0.005~0.30 HC per 5s video

See Also