Skip to main content
AI training plan generation lets coaches create a full structured training plan in two steps: first, the AI produces a written draft that you can read and edit, then you send that draft back to have it converted into individual workouts. This two-step flow keeps you in control — you can refine the plan’s intent before any workouts are created.
Training plan generation requires the Coach Agent feature on your organization’s plan. Contact your account manager if this feature isn’t available in your dashboard.

How the two-step process works

The generation process is intentionally split so you can apply your coaching judgment before committing to a full set of workouts.
1

Generate a draft

Send the basic plan parameters — number of weeks, athlete level, and any specific requirements — and the AI produces a readable training plan draft in text form.
2

Review and edit the draft

Read the draft in the app. You can edit the text directly to adjust volume, tweak the structure, add notes, or change the emphasis before moving on.
3

Generate the full plan

Submit the (optionally edited) draft back to the API. The AI converts it into individual structured workouts with names, descriptions, target durations, distances, and workout types — one entry per training day.

Step 1: Generate a draft

Endpoint: POST /api/v1/ai-coach/generate-draft

Request parameters

ParameterTypeRequiredDescription
weeksintegerYesLength of the plan in weeks. Must be between 1 and 52.
levelstringYesAthlete level: beginner, intermediate, or advanced.
org_idstringYesYour organization ID. Used to fetch your configured training principle.
additional_promptstringNoFree-text field for specific requirements, e.g. “athlete is targeting a sub-4 hour marathon” or “include one trail run per week”.
training_principlestringNoOverride your organization’s default training principle for this request only.
start_datestringNoISO date for the first day of the plan (YYYY-MM-DD). If omitted, workouts are scheduled relative to week/day numbers.
workout_preferencestringNoHow the AI sources workouts. See workout preference options below. Defaults to ai_generate.

Workout preference options

ValueBehavior
ai_generateAI creates all workouts from scratch (default).
prefer_existingAI reuses existing workouts from your library where possible, generating new ones when there’s no match.
strict_existingAI only uses workouts already in your library. No new workouts are generated.

Example request

curl -X POST https://api.nexrex.ai/api/v1/ai-coach/generate-draft \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "weeks": 12,
    "level": "intermediate",
    "org_id": "org_abc123",
    "additional_prompt": "Athlete is targeting a half marathon. Prefers running 4 days per week.",
    "start_date": "2026-05-05"
  }'

Example response

{
  "status": "success",
  "data": {
    "draft": "12-Week Intermediate Half Marathon Training Plan\n\nPhase 1 (Weeks 1–4): Base Building\nFocus on aerobic foundation with easy runs at conversational pace...\n\nWeek 1:\n- Monday: Rest\n- Tuesday: Easy run 45 min\n- Wednesday: Cross-training or rest\n- Thursday: Tempo run 30 min\n- Friday: Rest\n- Saturday: Long run 10 km\n- Sunday: Rest\n...",
    "training_principle": "Progressive overload with 80/20 easy-hard split. Prioritize aerobic base before adding speed work.",
    "metadata": {
      "weeks": 12,
      "level": "intermediate",
      "org_id": "org_abc123",
      "generated_at": "2026-04-23T10:15:00Z"
    }
  }
}

Step 2: Generate the full plan

Once you’ve reviewed and optionally edited the draft text, submit it back to convert it into structured workouts. Endpoint: POST /api/v1/ai-coach/generate-plan

Request parameters

All parameters from the draft request, plus:
ParameterTypeRequiredDescription
refined_draftstringYesThe draft text from step 1, with any edits you’ve made. Must be at least 10 characters.
The refined_draft field is where your edits matter. If you added a race-day workout, removed a rest day, or changed the weekly structure, make those changes in the draft text before sending this request.

Example request

curl -X POST https://api.nexrex.ai/api/v1/ai-coach/generate-plan \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "weeks": 12,
    "level": "intermediate",
    "org_id": "org_abc123",
    "refined_draft": "12-Week Intermediate Half Marathon Training Plan\n\n[your edited draft text here]"
  }'

Example response

{
  "status": "success",
  "data": {
    "content": [
      {
        "week": 1,
        "phase": "base",
        "day": "Tuesday",
        "workout_name": "Easy Base Run",
        "workout_description": "Comfortable aerobic run at conversational pace. Focus on building your aerobic foundation.",
        "workout_type": "run",
        "workout_sub_type": "easy-run",
        "target_duration_in_seconds": 2700,
        "target_distance_in_meters": 7000,
        "content_blocks": []
      },
      {
        "week": 1,
        "phase": "base",
        "day": "Thursday",
        "workout_name": "Tempo Run",
        "workout_description": "Comfortably hard effort at your half marathon goal pace.",
        "workout_type": "run",
        "workout_sub_type": "tempo-run",
        "target_duration_in_seconds": 1800,
        "target_distance_in_meters": 5000,
        "content_blocks": []
      }
    ],
    "weekly_info": {
      "1": { "phase": "base", "focus": "Aerobic foundation" },
      "2": { "phase": "base", "focus": "Build volume" }
    }
  }
}

Streaming endpoints

For long plans, the standard endpoints wait until generation is complete before returning a response. The streaming endpoints let you show progress in real time.
Endpoint: POST /api/v1/ai-coach/generate-draft/streamSame request body as /generate-draft. Returns a Server-Sent Events (SSE) stream.SSE event types:
TypePayload
progress{ "type": "progress", "status": "thinking", "message": "...", "progress": 50 }
result{ "type": "result", "data": { ... } } — the complete draft result
error{ "type": "error", "error": "..." }
done{ "type": "done" }
Use the incremental streaming endpoint (/stream-content) when building a UI that shows workouts populating progressively. For a 12-week plan with 4 training days per week, this gives users visual feedback as each of the ~48 workouts appears rather than waiting for the full batch.

Training principles

The AI uses your organization’s training principle when writing the plan — this is the coaching philosophy that shapes how volume, intensity, and recovery are structured across the weeks. You can view or update your organization’s training principle via GET /api/v1/ai-coach/training-principle/{org_id}. To override the training principle for a single request without changing your organization’s default, pass the training_principle field in the request body.

Access requirements

  • You must be authenticated as a coach role
  • Your organization must have the Coach Agent feature enabled
Attempting to use these endpoints without the required feature returns a 403 response.