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

# Agent Project Setup

> Use Trio REST APIs in coding-agent workflows with OpenAPI-driven scaffolding

## Goal

Set up a coding agent to build features on top of Trio REST APIs with a repeatable workflow.

## OpenAPI Source

Use the OpenAPI schema as:

* Published docs link: [OpenAPI JSON](/openapi.json)

## Bootstrap Prompt (Copy-Paste)

```text theme={null}
You are an AI coding agent building a Trio REST API integration.

Sources of truth:
- OpenAPI schema: docs/openapi.json (repo) or /openapi.json (published). Do not invent fields.
- Base URL: https://trio.machinefi.com/api
- Error handling: /guides/debugging

Deliverables:
1) Typed API client with auth + JSON support.
2) Endpoint wrappers:
   - POST /streams/validate
   - POST /check-once
   - POST /live-monitor
   - POST /live-digest
   - GET /jobs
   - GET /jobs/{job_id}
   - DELETE /jobs/{job_id}
3) Workflow functions:
   - Preflight: validate_stream (consume parsed_url from response when needed)
   - Sync check: check_once (returns triggered/explanation/latency)
   - Async monitor: live_monitor -> poll_job_until_terminal -> optional cancel_job
   - Async digest: live_digest -> webhook/SSE if configured; otherwise poll like monitor
4) Error handling:
   - parse error response shape: { "error": { "code", "message", "remediation" } }
   - handle 400/404/422/429 with actionable messages; treat JOB_NOT_FOUND as terminal
5) Tests:
   - success path: validate -> live-monitor -> poll to terminal (mocked)
   - success path: check-once returns triggered/explanation/latency (mocked)
   - failure path: validate fails (INVALID_URL or NOT_LIVESTREAM)

Request details (from OpenAPI):
- ValidateStreamRequest: { stream_url }
- CheckOnceRequest: { stream_url, condition, input_mode, clip_duration_seconds, include_frame }
- LiveMonitorRequest: { stream_url, condition, interval_seconds, input_mode, clip_duration_seconds, webhook_url, monitor_duration_seconds, trigger_cooldown_seconds, max_triggers }
- LiveDigestRequest: { stream_url, window_minutes, capture_interval_seconds, include_frames, max_windows, webhook_url }
- Job status enum: pending | running | stopped | completed | failed

Constraints:
- Use Authorization: Bearer <API_KEY> and Content-Type: application/json
- Add request timeouts; retry/backoff only on 429 or transient network errors
- Emit structured logs for each step (validate, check, start, poll, cancel)
- Return clean, typed results for client callers

Output:
- Provide usage examples for the client and workflows.
```

## Minimal Integration Flow

1. Validate URL with [Validate Stream](/api-reference/streams-validate).
2. Start job with [Live Monitor](/api-reference/live-monitor).
3. Poll [Get Job Details](/api-reference/jobs-get) until terminal status.
4. Use [Cancel Job](/api-reference/jobs-delete) if workflow aborts.
5. For push delivery, add [Webhooks](/guides/webhooks).

## Next Steps

* [MCP Integration](/integrations/mcp-integration) for direct agent tooling
* [Debugging Playbook](/guides/debugging) for resilient retries
* [How Trio Works](/core-concepts/how-trio-works)
