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

# Build With Your Coding Agent

> Point Claude Code, Codex, Cursor, or any coding agent at OpenTrain's machine-readable docs and let it build your platform integration autonomously.

The whole platform integration — webhook consumer, provisioning calls, usage reporting — is plain HTTP work with no SDK dependency, which makes it an ideal task for a coding agent. Every contract it needs is machine-readable: the Platform API ships a served OpenAPI spec, and every page of these docs exports as clean Markdown. Give your agent those URLs and a goal, and it can build, test, and harden the integration in one session. The [reference integration](/docs/developers/annotation-platforms/reference-integration) on the next page was built exactly this way.

## Give Your Agent the Docs

Three surfaces cover everything; none of them require authentication:

| Surface                                                                                                        | What it contains                                                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`https://app.opentrain.ai/api/partner/v1/openapi.json`](https://app.opentrain.ai/api/partner/v1/openapi.json) | The Platform API's OpenAPI spec — the machine-readable contract of record for every endpoint, parameter, and response shape. Generated from the same code that serves the requests.                                                              |
| [`https://www.opentrain.ai/docs/llms.txt`](https://www.opentrain.ai/docs/llms.txt)                             | Index of all documentation pages with one-line summaries ([`llms-full.txt`](https://www.opentrain.ai/docs/llms-full.txt) is the whole site in one file).                                                                                         |
| Any docs page + `.md`                                                                                          | Append `.md` to any page URL for clean Markdown — for example [`/docs/developers/annotation-platforms/webhooks.md`](https://www.opentrain.ai/docs/developers/annotation-platforms/webhooks.md). Code blocks and tab contents survive the export. |

The pages worth feeding in full, in reading order: [overview](/docs/developers/annotation-platforms/overview), [register your app](/docs/developers/annotation-platforms/register-your-app), [consent and installs](/docs/developers/annotation-platforms/consent-and-installs), [project links](/docs/developers/annotation-platforms/project-links), [webhooks](/docs/developers/annotation-platforms/webhooks), [usage sync](/docs/developers/annotation-platforms/usage-sync), and the [reference integration](/docs/developers/annotation-platforms/reference-integration).

## A Bootstrap Prompt

Adapt and paste this into your agent to start the session:

```text theme={null}
You are building an OpenTrain integration for <YOUR PLATFORM>, an annotation
platform. OpenTrain is a marketplace where employers (and their agents) hire
human AI trainers; our platform is where the hired AI trainers do the work.

Fetch this context first:
1. https://www.opentrain.ai/docs/llms.txt — docs index; fetch any page with .md appended
2. https://app.opentrain.ai/api/partner/v1/openapi.json — Platform API spec (no auth needed)
3. In full:
   - https://www.opentrain.ai/docs/developers/annotation-platforms/overview.md
   - https://www.opentrain.ai/docs/developers/annotation-platforms/webhooks.md
   - https://www.opentrain.ai/docs/developers/annotation-platforms/usage-sync.md
   - https://www.opentrain.ai/docs/developers/annotation-platforms/reference-integration.md

Build a webhook consumer that:
- verifies X-OpenTrain-Signature (t=...,v1=... HMAC-SHA256 over "<t>.<rawBody>")
  and dedupes by X-OpenTrain-Delivery
- on contract.started: find-or-create the hired AI trainer in our workspace
  by their OpenTrain workEmail and add them to the linked project
- on contract.ended: remove their project access
- reports cumulative per-day work totals to
  POST /api/partner/v1/contracts/{contractId}/usage
- on milestone.budget_low / milestone.budget_depleted: surface a "funded
  budget is running out — top up on OpenTrain" notice in our UI

Constraints:
- The platform token is in env OPENTRAIN_PARTNER_TOKEN (ot_ptk_...); the
  webhook secret is in OPENTRAIN_WEBHOOK_SECRET. Never print either.
- Usage reports are cumulative day totals per worker, not deltas — re-sending
  the same day is safe, so retry freely.
- Use only our platform's existing user/membership APIs on our side.
```

<Tip>
  Keep a human in the loop where OpenTrain does: anything that moves money
  (funding, payment release, ending a funded contract) is
  [co-signed](/docs/developers/concepts/human-approvals) on OpenTrain itself, so
  your agent can build and test the full loop without being able to spend
  anything.
</Tip>

## Optional: Let Your Agent Drive the Employer Side

Testing the integration end-to-end needs an employer on the other side — someone to post a job, link it to your project, and hire. Your agent can play that role too: the [OpenTrain MCP server](/docs/developers/mcp/overview) exposes the employer surface (jobs, proposals, contracts, milestones) as tools, using a separate personal `ot_pat_` token from an employer test account. The same surface is available as a [CLI](/docs/developers/cli/commands) and [plain HTTP](/docs/developers/api-reference/overview).

<AccordionGroup>
  <Accordion title="Claude Code">
    ```bash theme={null}
    claude mcp add opentrain --env OPENTRAIN_PERSONAL_API_TOKEN=ot_pat_... -- npx -y @opentrain-ai/mcp
    ```

    Add `--scope user` to make it available in every project. Full setup: [Claude Code](/docs/developers/agents/claude-code).
  </Accordion>

  <Accordion title="Codex CLI">
    ```bash theme={null}
    codex mcp add opentrain --env OPENTRAIN_PERSONAL_API_TOKEN=ot_pat_... -- npx -y @opentrain-ai/mcp
    ```

    Or declare it in `~/.codex/config.toml`. Full setup: [Codex CLI](/docs/developers/agents/codex-cli).
  </Accordion>

  <Accordion title="Cursor">
    `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):

    ```json theme={null}
    {
      "mcpServers": {
        "opentrain": {
          "command": "npx",
          "args": ["-y", "@opentrain-ai/mcp"],
          "env": { "OPENTRAIN_PERSONAL_API_TOKEN": "ot_pat_..." }
        }
      }
    }
    ```

    Full setup (including keeping the token out of JSON with `envFile`): [Cursor](/docs/developers/agents/cursor).
  </Accordion>

  <Accordion title="Antigravity">
    `~/.gemini/config/mcp_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "opentrain": {
          "command": "npx",
          "args": ["-y", "@opentrain-ai/mcp"],
          "env": { "OPENTRAIN_PERSONAL_API_TOKEN": "ot_pat_..." }
        }
      }
    }
    ```

    Full setup: [Antigravity](/docs/developers/agents/antigravity).
  </Accordion>

  <Accordion title="Grok Build">
    Reads Claude Code-format `.mcp.json` at the project root (same `mcpServers` shape as Cursor above), or use the `/mcps` modal in-session. Full setup: [Grok Build](/docs/developers/agents/grok-build).
  </Accordion>

  <Accordion title="GitHub Copilot CLI">
    Run `/mcp add` in-session, or edit `~/.copilot/mcp-config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "opentrain": {
          "type": "stdio",
          "command": "npx",
          "args": ["-y", "@opentrain-ai/mcp"],
          "env": { "OPENTRAIN_PERSONAL_API_TOKEN": "${OPENTRAIN_PERSONAL_API_TOKEN}" }
        }
      }
    }
    ```

    Full setup: [Copilot CLI](/docs/developers/agents/copilot-cli).
  </Accordion>

  <Accordion title="OpenCode">
    `opencode.json` — note the key is `mcp`, the command is an array, and env lives under `environment`:

    ```json theme={null}
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "opentrain": {
          "type": "local",
          "command": ["npx", "-y", "@opentrain-ai/mcp"],
          "environment": { "OPENTRAIN_PERSONAL_API_TOKEN": "{env:OPENTRAIN_PERSONAL_API_TOKEN}" },
          "enabled": true
        }
      }
    }
    ```

    Full setup: [OpenCode](/docs/developers/agents/opencode).
  </Accordion>

  <Accordion title="Aider">
    Aider has no MCP support — use the CLI instead:

    ```bash theme={null}
    npm install -g @opentrain-ai/cli
    opentrain auth login --api-key ot_pat_...
    ```

    Then run commands from the chat with `/run opentrain ... --json`. Full setup: [Aider](/docs/developers/agents/aider).
  </Accordion>

  <Accordion title="Any other MCP agent">
    Any MCP-capable agent works with the generic `mcpServers` shape — `command: "npx"`, `args: ["-y", "@opentrain-ai/mcp"]`, token in `env`. Examples for Claude Desktop and Windsurf: [Other MCP Agents](/docs/developers/agents/other-mcp-agents).
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={3}>
  <Card title="Register Your App" href="/docs/developers/annotation-platforms/register-your-app" icon="rocket">
    Self-serve: create the app, get your client credentials, send your first consent link.
  </Card>

  <Card title="Reference Integration" href="/docs/developers/annotation-platforms/reference-integration" icon="code">
    The complete worked example your agent can use as a blueprint.
  </Card>

  <Card title="Usage Sync and Budgets" href="/docs/developers/annotation-platforms/usage-sync" icon="gauge">
    Report work back and keep funded budgets ahead of consumption.
  </Card>
</CardGroup>
