API Reference
skill() Function
API reference for the skill() function to define monetized skills.
skill() Function
Define a monetized skill with pricing and handler.
Signature
Parameters
options
| Property | Type | Default | Description |
|---|---|---|---|
price | string | Required | Price per call (e.g., '$0.001') |
description | string | - | Skill description |
timeout | number | 60000 | Max execution time in ms |
inputSchema | JsonSchema | - | JSON Schema for input |
outputSchema | JsonSchema | - | JSON Schema for output |
Price Formats
| Format | Example | Parsed Amount |
|---|---|---|
| Dollar prefix | '$0.001' | 0.001 USDC |
| Currency suffix | '0.005 USDC' | 0.005 USDC |
| Plain number | '0.01' | 0.01 USDC |
Timeout Limits
- Minimum: 1ms
- Maximum: 300000ms (5 minutes)
- Default: 60000ms (1 minute)
handler
An async function that:
- Receives input from the caller
- Returns the result
- Throws on error (returns 500 to caller)
Returns
Examples
Basic Skill
Typed Skill
With JSON Schema
With Custom Timeout
Error Handling
Throw errors to return a 500 response:
In production (NODE_ENV=production), error messages are masked to prevent information disclosure.
Validation
The function validates:
- Price format (must be parseable)
- Timeout value (must be positive, max 5 minutes)