Install
openclaw skills install agentic-api-transformerTransform existing API systems to follow the Agentic API Spec design with dynamic discovery and progressive disclosure
openclaw skills install agentic-api-transformerThis skill helps you transform existing API systems to follow the Agentic API Spec design. It enables AI agents to discover APIs dynamically at runtime instead of loading massive static documentation upfront.
Use this skill when:
relates fields to API responses for progressive disclosure/api/llms.txt entry points for API discoveryCore concepts:
When the user asks to transform their API to the Agentic API format:
Tool: Use API analysis utilities to scan existing endpoints Available approaches:
data, error, relatesTASK_LOCKED, INVALID_PARAM)relates arrays with next-step actionsTool: Use response transformation utilities Available approaches:
/api/llms.txt endpoint for API discoveryTool: Use entry point generators Available approaches:
Tool: Use code template systems Available approaches:
data, error, relates fieldsrelates entries have method, path, desc, schemaTool: Use API validation utilities Available approaches:
After transformation, present:
/api/llms.txt contentTASK_LOCKED, not generic messages)relates entry must include method, path, desc, and schema# Analyze existing API (using OpenAPI parser)
# Example: Use swagger-parser or similar library
# Transform responses (using middleware)
# Example: Create response wrapper in your framework
# Output format:
# {
# "data": {"id": "task_123", "title": "Fix bug"},
# "error": null,
# "relates": [
# {
# "method": "PUT",
# "path": "/tasks/{id}",
# "desc": "Update task info",
# "schema": "interface UpdateTask { title?: string; completed?: boolean; }"
# }
# ]
# }
# Task Manager API
Manage tasks and projects with AI-friendly endpoints.
## Entry APIs
### POST /tasks
desc: Create a new task with specified priority
schema: interface CreateTask { title: string; priority: 'low' | 'medium' | 'high'; }
### GET /tasks
desc: List all tasks with pagination
schema: interface ListTasks { page?: number; limit?: number; }
Generate this file using:
// Express.js middleware example
app.use((req, res, next) => {
const originalSend = res.send;
res.send = function(data) {
const transformed = {
data: data,
error: null,
relates: generateRelates(req.path, req.method)
};
originalSend.call(this, transformed);
};
next();
});
# FastAPI middleware example
from fastapi import Request, Response
import json
async def agentic_middleware(request: Request, call_next):
response = await call_next(request)
if response.headers.get("content-type", "").startswith("application/json"):
data = json.loads(response.body)
transformed = {
"data": data,
"error": None,
"relates": generate_relates(request.url.path, request.method)
}
response.body = json.dumps(transformed).encode()
return response
Similar patterns apply to Spring Boot, Go/Gin, and other frameworks.
All transformed APIs must return this structure:
{
"data": {}, // Business data (current state)
"error": { // Error control
"code": "STABLE_ERROR_CODE",
"message": "Human-readable message"
},
"relates": [ // Related actions (future options)
{
"method": "GET|POST|PUT|DELETE",
"path": "/path/to/resource",
"desc": "Brief description of the API's intent and parameters",
"schema": "type Schema = { param: string; }"
}
]
}
# Project Name
Project description, usage guide, and authentication info.
## Entry APIs
### POST /tasks
desc: Create a new task with specified priority
schema: interface CreateTask { title: string; priority: 'low' | 'medium' | 'high'; }
### GET /tasks
desc: List all tasks with pagination
schema: interface ListTasks { page?: number; limit?: number; }
Problem: Responses don't include next-step actions
Fix: Ensure resource relationship mapping in analyzer, check relates generation logic
Problem: Schema validation fails
Fix: Use TypeScript interface syntax, validate with TypeChat parser
Problem: Compliance checks fail
Fix: Review validation report, fix missing fields, ensure stable error codes
For complex workflows with conditional next steps:
# For complex workflows with conditional next steps:
# Use business logic to determine relates based on:
# - Current resource state
# - User permissions/roles
# - Workflow stage
# - Contextual factors
# Example logic (pseudocode):
if current_state == 'pending' and user.can_approve:
relates.append({
'method': 'POST',
'path': '/approvals',
'desc': 'Approve pending request',
'schema': 'type Approve = { request_id: string; }'
})
Transform your APIs for the AI agent era!