Publish a Version
curl -X POST https://api.trainlyai.com/v1/{project_id}/versions \
-H "Authorization: Bearer tk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"version": "1.3.0",
"description": "Switch to gpt-4o, tighten system prompt for conciseness."
}'
POST /v1/{project_id}/versions
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
version | string | Yes | Semver version string (e.g. "1.3.0") |
description | string | No | Summary of changes in this version |
Response
{
"version_id": "ver_j1k2l3m4",
"version": "1.3.0",
"created_at": "2026-04-07T15:00:00Z"
}
List Versions
curl "https://api.trainlyai.com/v1/{project_id}/versions" \
-H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/versions
Response
[
{
"version_id": "ver_j1k2l3m4",
"version": "1.3.0",
"description": "Switch to gpt-4o, tighten system prompt for conciseness.",
"is_active": true,
"created_at": "2026-04-07T15:00:00Z"
},
{
"version_id": "ver_f5g6h7i8",
"version": "1.2.0",
"description": "Add few-shot examples to system prompt.",
"is_active": false,
"created_at": "2026-03-28T10:30:00Z"
}
]
Get Version Details
curl "https://api.trainlyai.com/v1/{project_id}/versions/ver_j1k2l3m4" \
-H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/versions/{version_id}
Response
{
"version_id": "ver_j1k2l3m4",
"version": "1.3.0",
"description": "Switch to gpt-4o, tighten system prompt for conciseness.",
"is_active": true,
"trace_count": 1240,
"avg_latency_ms": 695.3,
"avg_cost": 0.0031,
"created_at": "2026-04-07T15:00:00Z"
}
Rollback to a Version
curl -X POST https://api.trainlyai.com/v1/{project_id}/versions/ver_f5g6h7i8/rollback \
-H "Authorization: Bearer tk_your_api_key"
POST /v1/{project_id}/versions/{version_id}/rollback
Response
{
"version_id": "ver_f5g6h7i8",
"version": "1.2.0",
"is_active": true,
"rolled_back_at": "2026-04-07T15:30:00Z"
}
Compare Versions
curl "https://api.trainlyai.com/v1/{project_id}/versions/compare?a=ver_f5g6h7i8&b=ver_j1k2l3m4" \
-H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/versions/compare
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
a | string | Yes | First version ID |
b | string | Yes | Second version ID |
Response
{
"version_a": {
"version_id": "ver_f5g6h7i8",
"version": "1.2.0",
"avg_latency_ms": 812.1,
"avg_cost": 0.0028,
"total_traces": 8430,
"error_rate": 0.012
},
"version_b": {
"version_id": "ver_j1k2l3m4",
"version": "1.3.0",
"avg_latency_ms": 695.3,
"avg_cost": 0.0031,
"total_traces": 1240,
"error_rate": 0.008
},
"diff": {
"latency_change_pct": -14.4,
"cost_change_pct": 10.7,
"error_rate_change_pct": -33.3
}
}