> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videodb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox Compute

> Run supported open-weight and specialized models in VideoDB workflows by starting a sandbox and passing sandbox_id.

Sandbox Compute is VideoDB's managed runtime for supported open-weight and specialized models.

Create a sandbox, wait until it is active, then pass `sandbox_id` to supported APIs. VideoDB routes that job to your sandbox runtime instead of the default hosted path.

Sandbox is not only an indexing feature. It can power object detection analyzers, indexing pipelines, transcription, and generation workflows such as text-to-speech and text generation.

For hosted/default models, omit `sandbox_id`. For Sandbox Compute/open-weight models, pass `sandbox_id` explicitly.

> [card] [Try the Sandbox quickstart notebook](https://github.com/video-db/videodb-cookbook/blob/preview/guides/sandbox/quickstart.ipynb)
>
> Create a sandbox and run supported models in a hands-on example.

***

## When to use Sandbox Compute

Use Sandbox Compute when you want:

* **Open-weight model access** for object detection, speech, or text workflows.
* **Specialized models** such as Qwen3-4B, Whisper, OmniVoice, or RT-DETR.
* **Predictable routing** by pinning a job to a specific sandbox ID.
* **Runtime-based pricing** for compatible workloads.

***

## Create a sandbox

Choose a tier based on the largest model you plan to run. Creating a sandbox returns immediately while compute is provisioning.

```python theme={null}
import videodb
from videodb import SandboxTier

conn = videodb.connect()
coll = conn.get_collection()

sandbox = conn.create_sandbox(
    tier=SandboxTier.small,
    models=["Qwen/Qwen3-4B"],
)

sandbox.wait_for_ready(timeout=300, interval=5)
print(sandbox.id)
```

You can prepare the sandbox by model category instead of exact model names:

```python theme={null}
sandbox = conn.create_sandbox(
    tier=SandboxTier.small,
    model_categories=["text_generation", "object_detection", "text_to_speech"],
)

sandbox.wait_for_ready()
```

Supported category names include:

| Category | Use for |
| - | - |
| `object_detection` | object detection models such as RT-DETR |
| `speech_to_text` | speech recognition models such as Whisper |
| `text_to_speech` | speech generation models such as OmniVoice |
| `text_generation` | text generation models such as Qwen3-4B |

> [!NOTE]
>
> Submit sandbox-backed jobs only after the sandbox is active.

***

## Pick a model

Sandbox supports text generation, vision, speech-to-text, text-to-speech, and object detection models. Qwen3.5-9B requires the `medium` tier; the other listed models run on `small`.

> [card] [Sandbox Models](https://docs.videodb.io/pages/core-concepts/sandbox-models.md)
>
> See the current model catalog and minimum tier for each model.

***

## Route jobs to the sandbox

Pass `sandbox_id=sandbox.id` to supported APIs.

If `sandbox_id` is omitted, VideoDB uses the hosted/default path. For production workflows with Sandbox models, pass the ID explicitly so routing is predictable.

***

## Use Sandbox with Understanding and Indexing

Sandbox affects the [**understanding** step](https://docs.videodb.io/pages/understand/indexing-pipelines/understanding-artifacts.md): it controls where the model runs. The **indexing** step is unchanged: index the resulting artifact with `video.index(...)`.

For sandbox-backed object detection, choose the detection model in the analyzer config. Configure object filters and aggregations when you create the index.

```python theme={null}
sandbox = conn.create_sandbox(
    tier=SandboxTier.small,
    models=["rtdetr-v2-r50vd"],
)
sandbox.wait_for_ready()

video = coll.get_video("m-xxx")

understanding = video.understand(
    analyzers=[
        {
            "type": "object_detection",
            "name": "objects",
            "config": {
                "model": "rtdetr-v2-r50vd",
                "sandbox_id": sandbox.id,
            },
        }
    ],
)

understanding.wait_until_complete()
objects = understanding.get_analyzer("objects")

video.index(
    name="objects",
    source=objects,
    use_for=["query", "aggregate"],
    fields={
        "filter": ["object_labels", "object_counts"],
        "aggregate": ["object_labels"],
    },
)
```

For complete indexing options, see [Create an Index](https://docs.videodb.io/pages/understand/indexing-pipelines/create-an-index.md).

***

## Use Sandbox for generation workflows

Sandbox can also route supported generation jobs. These APIs use `model_name` plus `sandbox_id`.

```python theme={null}
sandbox = conn.create_sandbox(
    tier=SandboxTier.small,
    models=["k2-fsa/OmniVoice", "Qwen/Qwen3-4B"],
)
sandbox.wait_for_ready()
```

### OmniVoice text-to-speech

```python theme={null}
job = coll.generate_voice(
    text="Welcome to VideoDB Sandbox Compute.",
    model_name="k2-fsa/OmniVoice",
    sandbox_id=sandbox.id,
)

audio = job.wait(timeout=900, interval=5)
print(audio.id)
```

### Voice design

Use `config.instructions` to guide the voice style.

```python theme={null}
job = coll.generate_voice(
    text="Breaking update: your video workflows now have dedicated inference compute.",
    model_name="k2-fsa/OmniVoice",
    sandbox_id=sandbox.id,
    config={"instructions": "A deep, authoritative news anchor voice"},
)

audio = job.wait(timeout=900, interval=5)
```

### Reusable voice clone

Create a voice clone once from a reference audio asset, then reuse it by passing `voice_clone_id`.

```python theme={null}
ref_audio = coll.upload(
    url="https://www.youtube.com/shorts/8GrguhmR6oQ",
    media_type="audio",
)

voice_clone = coll.create_voice_clone(
    ref_audio_id=ref_audio.id,
    name="Product Narrator",
    description="Reusable narration voice",
    ref_text="Sample reference text for the audio clip",
    language="en",
)

job = coll.generate_voice(
    text="This narration uses a reusable voice clone.",
    model_name="k2-fsa/OmniVoice",
    sandbox_id=sandbox.id,
    voice_clone_id=voice_clone.id,
)

audio = job.wait(timeout=900, interval=5)
```

### Text generation

```python theme={null}
response = coll.generate_text(
    prompt="Summarize the key visual events from this scene description list.",
    model_name="Qwen/Qwen3-4B",
    sandbox_id=sandbox.id,
    max_tokens=300,
    temperature=0.2,
)

print(response)
```

***

## Validation and permissions

When you pass `sandbox_id`, VideoDB validates that:

1. the sandbox exists and belongs to your workspace/account,
2. the sandbox is active,
3. the sandbox tier supports the requested model,
4. the sandbox was created with a matching `models` or `model_categories` value, when model selection was provided.

If validation fails, create or start a compatible sandbox and retry the job with that sandbox ID.

***

## Manage sandboxes

```python theme={null}
# Refresh one sandbox
sandbox.refresh()
print(sandbox.status, sandbox.is_active)

# List sandboxes
for sb in conn.list_sandboxes():
    print(sb.id, sb.name, sb.tier, sb.status)

# Get a sandbox by ID
sb = conn.get_sandbox(sandbox.id)
print(sb)
```

***

## Stop the sandbox

Sandbox billing is based on runtime. Stop the sandbox when your workload is complete.

```python theme={null}
sandbox.stop()
sandbox.wait_for_stop(timeout=120, interval=5)
print(f"Sandbox {sandbox.id} final status: {sandbox.status}")
```

***

## Pricing and limits

Sandbox billing is runtime-based. Billing is recorded when the sandbox stops and is calculated from `started_at` to `stopped_at`, rounded to 2 decimal hours.

| Sandbox tier | Price |
| - | -: |
| `small` | `$1/hour` |
| `medium` | `$4.50/hour` |

| Sandbox tier | Concurrent sandbox limit | Max runtime |
| - | -: | -: |
| `small` | 5 | 24 hours |
| `medium` | 3 | 24 hours |

***

## Best practices

* Create one sandbox per workflow and reuse it across compatible jobs.
* Use the `small` tier unless you need Qwen3.5-9B, which requires `medium`.
* Use `models=[...]` when you know the exact models your workflow needs.
* Use `model_categories=[...]` when your workflow may use several models in the same category.
* Wait until the sandbox is active before submitting jobs.
* Pass `sandbox_id=sandbox.id` explicitly for production indexing and generation jobs.
* Use `job.wait(timeout=900, interval=5)` for long-running generation jobs.
* Log `sandbox.id` with each job so runs can be debugged or retried.
* Stop the sandbox when work is complete.

> [card] [Sandbox Models](https://docs.videodb.io/pages/core-concepts/sandbox-models.md)
>
> See supported models and minimum tiers.

> [card] [Understanding Artifacts](https://docs.videodb.io/pages/understand/indexing-pipelines/understanding-artifacts.md)
>
> Configure analyzers and model selection.

> [card] [Create an Index](https://docs.videodb.io/pages/understand/indexing-pipelines/create-an-index.md)
>
> Index artifacts produced by hosted or sandbox models.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.