AI Agents
TrainerStudio's API is designed to be consumed by AI agents. Whether you're using Claude, GPT, a custom agent, or an orchestration framework like LangChain — the API works the same way.
Why AI agents?
A coach managing 50+ clients spends hours on repetitive tasks: creating workout blocks, adjusting programs, checking compliance. An AI agent can handle these operations in seconds via the API, freeing the coach to focus on coaching.
Common agent workflows:
- Auto-programming: generate workout blocks based on client goals and history
- Client onboarding: create the client, assign an initial program, set up metrics
- Progress monitoring: read metrics and compliance data, flag clients who need attention
- Bulk operations: update programs for an entire group at once
Setup
1. Create a dedicated API key
Go to Settings → API Keys in the coach app and create a key named after your agent (e.g. "Claude agent", "Programming bot"). This keeps audit trails clean and lets you revoke the agent's access independently.
2. Give the agent the API reference
AI agents work best when they have the API schema. You can provide:
- This documentation — link the agent to these pages
- The OpenAPI spec — point the agent to
https://api.trainerstudio.io/swagger-json - An
llms.txtfile — available athttps://www.trainerstudio.com/llms.txt
3. Configure tool use
Most agent frameworks support "tool use" or "function calling". Define tools that map to TrainerStudio API endpoints:
{
"name": "create_customer",
"description": "Create a new client in TrainerStudio",
"parameters": {
"type": "object",
"properties": {
"name": { "type": "string", "description": "Client full name" },
"email": { "type": "string", "description": "Client email address" }
},
"required": ["name", "email"]
}
}The tool implementation is a simple HTTP call:
import httpx
def create_customer(name: str, email: str) -> dict:
response = httpx.post(
"https://api.trainerstudio.io/coach/customers",
headers={"X-API-Key": API_KEY},
json={"name": name, "email": email},
)
response.raise_for_status()
return response.json()Example: Claude with tool use
import anthropic
import httpx
client = anthropic.Anthropic()
TS_API_KEY = "your-trainerstudio-api-key"
TS_BASE = "https://api.trainerstudio.io"
tools = [
{
"name": "list_customers",
"description": "List all clients in TrainerStudio",
"input_schema": {
"type": "object",
"properties": {},
},
},
{
"name": "create_workout",
"description": "Create a workout block for a client on a given date",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {"type": "string"},
"name": {"type": "string"},
"date": {"type": "string", "description": "ISO date, e.g. 2026-05-15"},
},
"required": ["customer_id", "name", "date"],
},
},
]
def handle_tool(name, input):
headers = {"X-API-Key": TS_API_KEY}
if name == "list_customers":
r = httpx.get(f"{TS_BASE}/coach/customers", headers=headers)
return r.json()
elif name == "create_workout":
r = httpx.post(
f"{TS_BASE}/coach/customers/{input['customer_id']}/wblocks",
headers=headers,
json={"name": input["name"], "date": input["date"]},
)
return r.json()
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=tools,
messages=[
{"role": "user", "content": "Create a leg day workout for my client Ada tomorrow"}
],
)
# Process tool calls in the response
for block in message.content:
if block.type == "tool_use":
result = handle_tool(block.name, block.input)
print(f"Tool {block.name} returned: {result}")MCP server
TrainerStudio hosts an MCP server that lets AI assistants interact with your coaching data without writing any code. See the dedicated MCP Server page for setup instructions.
Rate limits
The API currently does not enforce strict rate limits, but be reasonable:
- Avoid more than 10 requests per second from a single key.
- Use bulk endpoints when available (e.g. duplicate date ranges instead of individual blocks).
- Cache exercise library lookups — they rarely change.
Tips for agent builders
- Start with read-only tools (list customers, get workouts) before adding write operations. This lets you validate the integration safely.
- Use the exercise library — search
/exercises/unifiedto find exercises by name rather than hardcoding IDs. - Include the client name in confirmations — when your agent creates or modifies data, have it confirm what it did with the client's name, not just the ID.
- Handle pagination — list endpoints return paginated results. Check for
limitandoffsetparameters. - Test with a sandbox client — create a test client to validate your agent's behavior before running it on real data.