Skip to main content
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 on the next page was built exactly this way.

Give Your Agent the Docs

Three surfaces cover everything; none of them require authentication:
SurfaceWhat it contains
https://app.opentrain.ai/api/partner/v1/openapi.jsonThe 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.txtIndex of all documentation pages with one-line summaries (llms-full.txt is the whole site in one file).
Any docs page + .mdAppend .md to any page URL for clean Markdown — for example /docs/developers/annotation-platforms/webhooks.md. Code blocks and tab contents survive the export.
The pages worth feeding in full, in reading order: overview, register your app, consent and installs, project links, webhooks, usage sync, and the reference integration.

A Bootstrap Prompt

Adapt and paste this into your agent to start the session:
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.
Keep a human in the loop where OpenTrain does: anything that moves money (funding, payment release, ending a funded contract) is co-signed on OpenTrain itself, so your agent can build and test the full loop without being able to spend anything.

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 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 and plain HTTP.
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.
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.
.cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
  "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.
~/.gemini/config/mcp_config.json:
{
  "mcpServers": {
    "opentrain": {
      "command": "npx",
      "args": ["-y", "@opentrain-ai/mcp"],
      "env": { "OPENTRAIN_PERSONAL_API_TOKEN": "ot_pat_..." }
    }
  }
}
Full setup: Antigravity.
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.
Run /mcp add in-session, or edit ~/.copilot/mcp-config.json:
{
  "mcpServers": {
    "opentrain": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@opentrain-ai/mcp"],
      "env": { "OPENTRAIN_PERSONAL_API_TOKEN": "${OPENTRAIN_PERSONAL_API_TOKEN}" }
    }
  }
}
Full setup: Copilot CLI.
opencode.json — note the key is mcp, the command is an array, and env lives under environment:
{
  "$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.
Aider has no MCP support — use the CLI instead:
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.
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.

Next Steps

Register Your App

Self-serve: create the app, get your client credentials, send your first consent link.

Reference Integration

The complete worked example your agent can use as a blueprint.

Usage Sync and Budgets

Report work back and keep funded budgets ahead of consumption.