Create a collection
A collection is one labeling run over a completed input folder or JSONL file manifest. It can contain one episode or thousands. An episode contains two synchronized camera views of the same recording.
Create a key in the console and set COSTPLUSIQ_API_KEY in your environment. Every labeling endpoint requires the same bearer authentication:
Authorization: Bearer $COSTPLUSIQ_API_KEY
Upload both views of every episode before submitting. Then send exactly two JSON fields:
curl --fail-with-body https://api.costplusiq.com/v1/labeling/collections \
-H "Authorization: Bearer $COSTPLUSIQ_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: recordings-run-17-v1" \
--data '{
"input": "r2://customer-videos/recordings/run-17/",
"output": "r2://customer-labels/labels/run-17/"
}'
| Field | Required value |
|---|---|
input | An R2 bucket, folder, or .jsonl manifest object connected to your account, within its allowed read scope. |
output | An R2 folder in a connected bucket with write access. It may be in the same bucket as the input, provided the input does not overlap the output or checkpoint paths. |
The service chooses the processing policy. The request body contains only input and output; file lists belong in a JSONL object. HTTP URLs and presigned URLs are not accepted in place of these two R2 locations. Download URLs inside a JSONL manifest must use hosts registered to your connection.
202 Accepted returns a collection object. Save its id; acceptance means the run is durable, while validation and labeling continue asynchronously. Example response, showing only the fields needed to begin tracking:
{
"id": "col_0123456789abcdef0123456789abcdef",
"state": "discovering",
"control": "running",
"episode_count": 0,
"counts": {},
"results_ready": false
}
The episode count fills in after discovery. IDs in this guide are illustrative; use the IDs returned by your own request.
Safe creation retries
Idempotency-Key is required: 8–128 characters from A–Z a–z 0–9 _ . : -. Save the key with your request. If the request times out or its response is lost, retry with the same key and the same locations. The service returns the same collection. Changing a location under that key returns 409.
Missing trailing slashes and equivalent percent encoding are normalized. A fresh key starts a separate run, even for the same input folder. Keep the original key when recovering a request.
Prepare the input folder
The default camera filenames are exact and case-sensitive:
r2://customer-videos/recordings/run-17/
episode-0001/
top_left.mp4
front_left.mp4
robot.json # optional non-video sidecar; ignored
episode-0002/
top_left.mp4
front_left.mp4
You can submit the bucket root, parent folder, or a single episode folder directly. A bucket-root input needs its output in a different bucket. Nested episode paths become your episode IDs; an episode at the input root uses that folder's name. A different pair of filenames must be configured when the bucket is connected. The service does not infer camera roles from filenames.
| Limit | Current contract |
|---|---|
| Camera views | Exactly two per episode: top_left and front_left. |
| Duration | Up to one hour per episode. The two view durations must differ by no more than one second. |
| Source size | Up to 2 GiB per view. |
| Collection size | Up to 10,000 episodes and 50,000 objects, including sidecars. The discovered inventory must fit within 8 MiB of JSON. |
Missing views, extra video filenames, duplicate episode identities, and empty folders fail validation. A collection below these limits can still wait for processing capacity.
Keep the submitted folder unchanged until preparation completes. Discovery is paginated, so it cannot take an atomic snapshot of a folder that is still receiving uploads. The service pins object sizes and ETags; a changed or missing pinned object fails validation instead of silently substituting new data. There is no append or streaming-upload contract.
Use a JSONL file list
For an explicit list, upload a UTF-8 JSONL manifest to a connected R2 bucket and use its object URI as input:
{
"input": "r2://customer-videos/manifests/run-17.jsonl",
"output": "r2://customer-labels/labels/run-17/"
}
Each physical line describes one episode. Camera roles are explicit, so source filenames and folder layouts can vary. Example line:
{"episode_id":"episode-0001","videos":[{"camera_role":"top_left","uri":"r2://source-videos/0001/eye.mp4","url":"https://videos.customer.example/0001/eye.mp4?signature=..."},{"camera_role":"front_left","uri":"r2://source-videos/0001/front.mp4","url":"https://videos.customer.example/0001/front.mp4?signature=..."}]}
| Field | Value |
|---|---|
episode_id | A unique, nonblank string of up to 256 characters, returned in your labels. |
videos | The two synchronized views. Each view has exactly camera_role, uri, and url. |
camera_role | top_left or front_left, once each. Array order does not matter. |
uri | The original R2 object reference. Its bucket must be registered for manifest inputs. This reference appears in the delivered labels. |
url | A public or signed HTTPS URL for that object, on an exact registered host. Redirects are rejected. URLs must remain valid through preparation and retries. |
The manifest supports up to 250,000 episodes, 4 GiB total, and 32 KiB per line. The same one-hour episode and 2 GiB view limits apply. Write one JSON object per line, with no blank lines, byte-order mark, duplicate fields, or extra fields. CSV is not accepted; convert your list to this JSONL format before submitting.
The service validates the entire manifest before processing videos. Duplicate episode IDs, unknown or duplicate camera roles, and unauthorized sources fail discovery. A missing view becomes an explicit failed episode while complete episodes proceed. A collection may wait for processing capacity after discovery.
Keep the manifest unchanged. The service pins its ETag and re-reads the pinned line when downloading each view. To replace expired URLs, upload a new manifest under a new key and start a new collection. Signed URLs stay out of checkpoints, logs, and delivered labels; restrict access to the manifest itself.
Track progress
Use the labeling console, or poll the collection endpoint about every 30 seconds. There are no completion webhooks yet.
COLLECTION_ID='col_0123456789abcdef0123456789abcdef'
curl --fail-with-body \
"https://api.costplusiq.com/v1/labeling/collections/$COLLECTION_ID" \
-H "Authorization: Bearer $COSTPLUSIQ_API_KEY"
The normal collection path is:
| Field | How to use it |
|---|---|
state | succeeded means all episodes were accepted. completed_with_errors means some episodes did not produce labels. failed and cancelled also stop the normal result-wait loop; inspect events before taking action. |
results_ready | When true, the collection manifest is published in your output folder. Read it even for a collection with errors. |
counts, episode_count | Episode counts by state and their total. An accepted episode has delivered labels. |
control | Requested control state: running, paused, cancelling, or cancelled. This is separate from processing state. |
wait_reason, attention | The current wait or issue. See the table below; a wait is not itself a failed run. |
next_action_at | A scheduled service action, not a predicted completion time. |
customer_billing | Your price, delivered episode hours, and the amount accrued and settled for this collection. |
Episodes and history
Each episode reports its id, its position as index, and its state: queued, running, accepted, failed, or cancelled. Events have a type: collection for state changes (discovering, running, succeeded, completed_with_errors, failed, cancelled), control for pause, resume and cancel requests, and episode for each episode's final outcome. Failed collections and episodes carry an error_code.
curl --fail-with-body \
"https://api.costplusiq.com/v1/labeling/collections/$COLLECTION_ID/episodes?limit=50" \
-H "Authorization: Bearer $COSTPLUSIQ_API_KEY"
curl --fail-with-body \
"https://api.costplusiq.com/v1/labeling/collections/$COLLECTION_ID/events?before=0&limit=100" \
-H "Authorization: Bearer $COSTPLUSIQ_API_KEY"
Collection and episode lists return {"data": [...], "next_cursor": ...}. Pass a non-null next_cursor back as cursor, URL-encoded, with the same filters. These are live pages: records can enter or leave a state filter while you browse.
For events, before=0 returns recent history in descending order; pass its next_cursor as before for older events. Forward consumers use after=0, then pass next_cursor as after. A page can hold fewer events than limit; keep following next_cursor. Add episode_id to see one episode's events. Use only one direction per request.
| Wait reason | What happens next |
|---|---|
waiting_capacity | Processing capacity is in use. Existing work continues; new work waits for a slot. |
delayed | Processing is delayed and the service retries automatically. Contact support if attention stays true; creating a duplicate collection does not help. |
Queue time varies, and there is no fixed completion deadline for the full collection.
Read the labels from R2
The metadata API returns progress; labels are written to the output location you supplied:
<output>/<collection_id>/manifest.json
<output>/<collection_id>/episodes/<opaque_episode_id>/labels.json
The collection manifest is written last. Its schema identifies the output version. Folder collections use bitrobot.labels.v2 (older runs use v1), with collection_id and an episodes array. JSONL collections use bitrobot.labels.v3, with episode_count and episode_shards instead of an inline episode array:
"episode_shards": [
{"path": "episode-shards/000000.json", "count": 128},
{"path": "episode-shards/000001.json", "count": 1}
]
Read each shard relative to the collection manifest's folder. Each has schema bitrobot.label-shard.v1, collection_id, and an episodes array. Both formats use these episode entries:
[
{
"episode_id": "episode-0001",
"id": "ep_0123456789abcdef0123456789abcdef",
"state": "accepted",
"labels": "episodes/ep_0123456789abcdef0123456789abcdef/labels.json"
},
{
"episode_id": "episode-0002",
"id": "ep_fedcba9876543210fedcba9876543210",
"state": "failed",
"labels": null
}
]
episode_id is your source folder identity or the ID supplied in your JSONL line. id is the opaque episode ID used by the API. Resolve a non-null labels path relative to the collection manifest's folder, including when reading a shard. Failed intake entries also include error_code. Do not assume every discovered episode has a labels file.
Each labels file contains your episode_id and an annotation array of start, end, and caption segments that cover the whole recording without gaps. Times are timestamp strings relative to the original recording. A usable segment's caption summarizes the task; an unusable segment's caption is unusable: <reason_code>. Example:
{
"episode_id": "episode-0001",
"annotation": [
{"start": "00:00.000", "end": "00:28.000", "caption": "unusable: no_relevant_activity"},
{"start": "00:28.000", "end": "02:00.018", "caption": "Person unpacks and sorts garments from a bag."}
]
}
The result pages (results/NNNNNN.jsonl) give each episode's original camera video references alongside its labels path or error.
Final outputs are immutable within a collection.
Endpoint reference
All paths below use https://api.costplusiq.com/v1/labeling. Reads and controls return 200 on success; collection creation returns 202.
| Method and path | Response |
|---|---|
GET /connections | data array of connected buckets, with id, name, and uri. Allowed prefixes and camera mappings are confirmed during onboarding. |
GET /recipes | data array with the labeling product name, retention policy, and price. No choice is accepted at creation. |
POST /collections | A collection object. Requires the two-location body and Idempotency-Key. |
GET /collections | Account-owned collection summaries. Accepts cursor, exact state, and limit (1–100; default 50). |
GET /collections/{id} | One collection with counts, controls, and billing. |
GET /collections/{id}/episodes | Episode objects with their states. Accepts cursor, exact state, and limit (1–100; default 50). |
GET /collections/{id}/episodes/{episode_id} | One episode object. |
GET /collections/{id}/events | data, next_cursor, and order. Accepts after or before, optional episode_id, and limit (1–500; default 100). |
POST /collections/{id}/pausePOST /collections/{id}/resumePOST /collections/{id}/cancel | The collection after the control request. No body is required. |
Ownership comes from your authenticated account. Another account's collection returns 404. Rotating a key within the same account and caller channel preserves access.
Pause, resume, cancel, and retry
curl --fail-with-body -X POST \
"https://api.costplusiq.com/v1/labeling/collections/$COLLECTION_ID/pause" \
-H "Authorization: Bearer $COSTPLUSIQ_API_KEY"
Replace pause with resume or cancel for the other controls. Pausing stops new work from starting; work already in progress finishes. Resume allows new work again.
Cancellation is asynchronous. control=cancelling means cancellation was requested, not that all work has stopped. Keep tracking until cancellation settles. Already delivered labels remain in R2. Cancellation may finish without a collection manifest, so do not wait indefinitely for results_ready.
The service retries transient failures automatically. Invalid inputs and repeated failures can still end in a failed episode. Pause, resume, and cancel do not replay terminal failed episodes.
Retry reads after temporary network errors, with backoff. After an uncertain create, reuse its original idempotency key. For a persistent collection failure, give support the collection ID and episode ID. Submit a new collection only when you intend to run the work again.
Errors
Check the HTTP status first. Coordinator errors may use {"error":{"code":"invalid_request"}} or {"detail":"labeling_account_not_enabled"}; gateway errors use an error object with a message and type. Clients should handle both error and detail.
| Status | What to check |
|---|---|
400 / 413 / 415 | Malformed or oversized metadata, unsupported content type or encoding. Send a small JSON body with the two locations. |
401 | Missing or invalid API key, or an unsupported batch-tier key. |
403 | The account is not enabled, or the key requests ZDR for this endpoint. |
404 | Unknown or inaccessible resource, or labeling is not enabled on that API origin. |
409 | An idempotency key was reused with different locations, or a control conflicts with the collection's state. |
422 | Invalid fields, missing/invalid idempotency key, unregistered or ambiguous locations, an out-of-scope prefix, or overlapping input/output paths. |
429 | Account admission or credit restriction. Read the error before retrying; insufficient credit needs a balance update. |
502 / 503 | A service connection failed, submissions are disabled, or a dependency is unavailable. Retry temporary failures with backoff and the original creation key. |
Failures discovered after 202 appear in collection, episode, and event metadata. A successful metadata GET does not mean the labeling work succeeded.
Pricing: $3.12 per episode hour
The production rate is $3.12 per input episode hour. Count the longest original camera duration once per episode. Two one-hour camera views of the same episode cost $3.12 total; ten six-minute episodes also total one episode hour.
Hourly billing is being rolled out. Your pilot's billing terms are confirmed when your account is enabled. Under the hourly plan, only episodes with delivered labels are charged, and processing retries add no charge.
Data handling and bucket access
Input connections need list/read access. Output connections need read/write access to the label destination and a configured artifact prefix used for preparation and recovery. Credentials are registered during onboarding; never include them in an API request.
The service writes intermediate artifacts under the configured artifact prefix and sends prepared videos to its model provider for processing. Source objects and final labels are not cleanup targets; prepared copies held for processing are deleted after use.
This labeling endpoint currently supports standard retention only. Do not use it for a workload that requires ZDR. Keep your input folder stable during preparation; this API does not lock your source bucket or prevent its owner from changing objects.