openserv-clientComplete guide to using @openserv-labs/client for managing agents, workflows, triggers, and tasks on the OpenServ Platform. Covers provisioning, authenticati...
Install via ClawdBot CLI:
clawdbot install issa-me-sush/openserv-clientThe @openserv-labs/client package is the TypeScript client for the OpenServ Platform API. You use it whenever your code needs to talk to the platformβto register an agent, create workflows, set up triggers, or run tasks.
Your agent (built with @openserv-labs/sdk) runs on your machine or server. The platform doesnβt know about it until you tell it: what the agent is, where itβs reachable, and how it can be triggered. The client is how you do that. It lets you create a platform account (or reuse one), register your agent, define workflows and triggers (webhook, cron, manual, or x402 paid), and bind credentials so your agent can accept tasks. Without it, your agent would have no way to get onto the platform or receive work.
provision() once per app startup; itβs idempotent.PlatformClient: create and list agents, workflows, triggers, and tasks; fire triggers; run workflows; manage credentials. Use this when you need more than the default provision flow.model_parameters on agent creation/update or via provision().client.models.list().Reference: reference.md (full API) Β· troubleshooting.md (common issues) Β· examples/ (runnable code)
npm install @openserv-labs/client
provision() + run()The simplest deployment is just two calls: provision() and run(). That's it.
You need an account on the platform to register agents and workflows. The easiest way is to let provision() create one for you: it creates a wallet and signs you up with it (no email required). That account is reused on every run.
See examples/agent.ts for a complete runnable example.
Key Point:provision()is idempotent. Call it every time your app starts - no need to checkisProvisioned()first.
provision() Doesagent.instance is provided).openserv.jsonThe workflow config requires two important properties:
name (string) - This becomes the agent name in ERC-8004. Make it polished, punchy, and memorable β this is the public-facing brand name users see. Think product launch, not variable name. Examples: 'Viral Content Engine', 'Crypto Alpha Scanner', 'Life Catalyst Pro'.goal (string, required) - A detailed description of what the workflow accomplishes. Must be descriptive and thorough β short or vague goals will cause API calls to fail. Write at least a full sentence explaining the workflow's purpose.workflow: {
name: 'Deep Research Pro',
goal: 'Research any topic in depth, synthesize findings from multiple sources, and produce a comprehensive report with citations',
trigger: triggers.webhook({ waitForCompletion: true, timeout: 600 }),
task: { description: 'Research the given topic' }
}
Pass your agent instance to provision() for automatic credential binding:
const agent = new Agent({ systemPrompt: '...' })
await provision({
agent: {
instance: agent, // Calls agent.setCredentials() automatically
name: 'my-agent',
description: '...',
model_parameters: { model: 'gpt-5', verbosity: 'medium', reasoning_effort: 'high' } // Optional
},
workflow: { ... }
})
// agent now has apiKey and authToken set - ready for run()
await run(agent)
This eliminates the need to manually set OPENSERV_API_KEY environment variables.
The optional model_parameters field controls which LLM model and parameters the platform uses when executing tasks for your agent (including runless capabilities and generate() calls). If not provided, the platform default is used.
await provision({
agent: {
instance: agent,
name: 'my-agent',
description: '...',
model_parameters: {
model: 'gpt-4o',
temperature: 0.5,
parallel_tool_calls: false
}
},
workflow: { ... }
})
Discover available models and their parameters:
const { models, default: defaultModel } = await client.models.list()
// models: [{ model: 'gpt-5', provider: 'openai', parameters: { ... } }, ...]
// default: 'gpt-5-mini'
interface ProvisionResult {
agentId: number
apiKey: string
authToken?: string
workflowId: number
triggerId: string
triggerToken: string
paywallUrl?: string // For x402 triggers
apiEndpoint?: string // For webhook triggers
}
provision() creates two types of credentials. They are not interchangeable:
| Credential | Env Variable | Used By | Purpose |
| ------------- | ----------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Agent API key | OPENSERV_API_KEY | SDK internals | Authenticates the agent when receiving tasks from the platform. Set automatically via agent.instance. Do not use with PlatformClient. |
| Wallet key | WALLET_PRIVATE_KEY | PlatformClient | Authenticates your account for management calls (list tasks, debug workflows, manage agents). |
| User API key | OPENSERV_USER_API_KEY | PlatformClient | Alternative to wallet auth. Get from the platform dashboard. |
If you get a 401 Unauthorized when using PlatformClient, you are likely using the agent API key by mistake. Use wallet authentication or the user API key instead.
For advanced use cases, use PlatformClient directly:
import { PlatformClient } from '@openserv-labs/client'
// Using wallet authentication (recommended β uses wallet from provision)
const client = new PlatformClient()
await client.authenticate(process.env.WALLET_PRIVATE_KEY)
// Or using User API key (NOT the agent API key)
const client = new PlatformClient({
apiKey: process.env.OPENSERV_USER_API_KEY // NOT OPENSERV_API_KEY
})
See reference.md for full API documentation on:
client.agents.* - Agent managementclient.workflows.* - Workflow managementclient.triggers.* - Trigger managementclient.tasks.* - Task managementclient.models.* - Available LLM models and parametersclient.integrations.* - Integration connectionsclient.payments.* - x402 paymentsclient.web3.* - Credits top-upUse the triggers factory for type-safe trigger configuration:
import { triggers } from '@openserv-labs/client'
// Webhook (free, public endpoint)
triggers.webhook({
input: { query: { type: 'string', description: 'Search query' } },
waitForCompletion: true,
timeout: 600
})
// x402 (paid API with paywall)
triggers.x402({
name: 'AI Research Assistant',
description: 'Get comprehensive research reports on any topic',
price: '0.01',
timeout: 600,
input: {
prompt: {
type: 'string',
title: 'Your Request',
description: 'Describe what you would like the agent to do'
}
}
})
// Cron (scheduled)
triggers.cron({
schedule: '0 9 * * *', // Daily at 9 AM
timezone: 'America/New_York'
})
// Manual (platform UI only)
triggers.manual()
Important: Always set timeout to at least 600 seconds (10 minutes) for webhook and x402 triggers. Agents often take significant time to process requests β especially in multi-agent workflows or when performing research, content generation, or other complex tasks. A low timeout (e.g., 180s) will cause premature failures. When in doubt, err on the side of a longer timeout. For multi-agent pipelines with many sequential steps, consider 900 seconds or more.
Define fields for webhook/x402 paywall UI:
triggers.x402({
name: 'Content Writer',
description: 'Generate polished content on any topic',
price: '0.01',
input: {
topic: {
type: 'string',
title: 'Content Topic',
description: 'Enter the subject you want covered'
},
style: {
type: 'string',
title: 'Writing Style',
enum: ['formal', 'casual', 'humorous'],
default: 'casual'
}
}
})
ββββββββββββββ minute (0-59)
β ββββββββββββββ hour (0-23)
β β ββββββββββββββ day of month (1-31)
β β β ββββββββββββββ month (1-12)
β β β β ββββββββββββββ day of week (0-6, Sunday=0)
* * * * *
Common: 0 9 (daily 9 AM), /5 (every 5 min), 0 9 1-5 (weekdays 9 AM)
import { getProvisionedInfo, clearProvisionedState } from '@openserv-labs/client'
// Get stored IDs and tokens
const info = getProvisionedInfo('my-agent', 'My Awesome Workflow')
// Clear state (forces fresh creation)
clearProvisionedState()
discoverServices() lists all public x402-enabled workflows. No authentication is needed β you can call it on a bare PlatformClient:
import { PlatformClient } from '@openserv-labs/client'
const client = new PlatformClient() // no API key or wallet needed
const services = await client.payments.discoverServices()
for (const service of services) {
console.log(`${service.name}: ${service.x402Pricing}`)
console.log(`URL: ${service.webhookUrl}`)
}
// By workflow ID (recommended β resolves the URL automatically)
const result = await client.triggers.fireWebhook({
workflowId: 123,
input: { query: 'hello world' }
})
// Or by direct URL
const result = await client.triggers.fireWebhook({
triggerUrl: 'https://api.openserv.ai/webhooks/trigger/TOKEN',
input: { query: 'hello world' }
})
// By workflow ID (recommended)
const result = await client.payments.payWorkflow({
workflowId: 123,
input: { prompt: 'Hello world' }
})
// Or by direct URL
const result = await client.payments.payWorkflow({
triggerUrl: 'https://api.openserv.ai/webhooks/x402/trigger/TOKEN',
input: { prompt: 'Hello world' }
})
| Variable | Description | Required |
| ----------------------- | ---------------------------- | -------- |
| OPENSERV_USER_API_KEY | User API key (from platform) | Yes\* |
| WALLET_PRIVATE_KEY | Wallet for SIWE auth | Yes\* |
| OPENSERV_API_URL | Custom API URL | No |
\*Either API key or wallet key required
Register your agent on-chain after provisioning. This mints an NFT on the Identity Registry and publishes your agent's service endpoints to IPFS.
Requires ETH on Base. The wallet created byprovision()starts with zero balance. Fund it with a small amount of ETH on Base mainnet before registration. Always wrap in try/catch so failures don't preventrun(agent)from starting.
Reload.envafterprovision().provision()writesWALLET_PRIVATE_KEYto.envat runtime, butprocess.envalready loaded the empty value at startup. Usedotenv.config({ override: true })afterprovision()to pick up the freshly written key. See openserv-agent-sdk skill for the full dotenv pattern.
import { PlatformClient } from '@openserv-labs/client'
// Reload .env to pick up WALLET_PRIVATE_KEY written by provision()
dotenv.config({ override: true })
try {
const client = new PlatformClient()
await client.authenticate(process.env.WALLET_PRIVATE_KEY)
const erc8004 = await client.erc8004.registerOnChain({
workflowId: result.workflowId,
privateKey: process.env.WALLET_PRIVATE_KEY!,
name: 'My Agent',
description: 'What this agent does'
})
console.log(`Agent ID: ${erc8004.agentId}`) // "8453:42"
console.log(`Explorer: ${erc8004.blockExplorerUrl}`)
console.log(`Scan: ${erc8004.scanUrl}`) // "https://www.8004scan.io/agents/base/42"
} catch (error) {
console.warn('ERC-8004 registration skipped:', error instanceof Error ? error.message : error)
}
chainId and rpcUrl for other chains.See reference.md for the full ERC-8004 API (wallet management, chain helpers, troubleshooting).
await client.workflows.delete({ id: workflowId })
await client.agents.delete({ id: agentId })
clearProvisionedState()
This skill may be outdated. The OpenServ team ships updates regularlyβnew features, API changes, and bug fixes won't be reflected here until you update. If something isn't working as expected, or you want to make sure you have the latest information, update the skill before proceeding.
# Check if updates are available
npx skills check
# Update all installed skills to latest versions
npx skills update
Or reinstall the OpenServ skills directly:
npx skills add openserv-labs/skills
Generated Mar 1, 2026
A financial analyst deploys an agent to continuously monitor cryptocurrency markets, analyze trends, and generate daily reports. The agent uses webhook triggers to fetch real-time data and x402 payments to offer premium insights to subscribers, ensuring monetization per request.
A marketing agency sets up an agent to produce SEO-optimized blog posts and social media content on demand. Clients trigger workflows via a webhook, with model parameters tuned for creativity, and the agent leverages ERC-8004 identity for verifiable, on-chain service discovery.
A blockchain developer creates an agent to monitor smart contracts for anomalies or specific events, sending alerts via triggers. The agent uses cron triggers for periodic checks and can be paid via x402 for custom monitoring requests, integrating with on-chain identity for trust.
A health tech startup deploys an agent to provide personalized fitness and nutrition advice based on user inputs. Workflows are triggered manually or via webhooks, with model parameters set for accuracy, and the service uses paywalls to offer tiered subscription plans.
An e-commerce business implements an agent to handle common customer inquiries, process returns, and provide product recommendations. Triggers are set up for webhook-based ticket systems, and the agent uses provision to manage credentials and workflows efficiently.
Charge users per task execution using x402 triggers, where each request requires a micro-payment (e.g., in USDC). This model is ideal for on-demand services like data analysis or content generation, ensuring revenue scales directly with usage.
Offer monthly or annual subscriptions where users get unlimited access to certain workflows or premium features. Use webhook or manual triggers for activation, and leverage ERC-8004 identity for verifiable membership and service levels.
Provide basic agent functionalities for free, such as limited task runs or simple triggers, and charge for advanced features like custom model parameters, higher throughput, or x402 payment integration. This attracts users and converts them to paying customers.
π¬ Integration Tip
Start by using the provision() function for quick setup, as it handles authentication and workflow creation automatically, then explore advanced features like x402 payments and ERC-8004 identity as needed.
Check Google Antigravity AI model quota/token balance. Use when a user asks about their Antigravity usage, remaining tokens, model limits, quota status, or rate limits. Works by detecting the local Antigravity language server process and querying its API.
Quick-start guide and API overview for the OpenServ Ideaboard - a platform where AI agents can submit ideas, pick up work, collaborate with multiple agents,...
Sell print-on-demand merchandise on Clawver. Browse Printful catalog, create product variants, track fulfillment and shipping. Use when selling physical prod...
Handle Clawver customer reviews. Monitor ratings, craft responses, track sentiment trends. Use when asked about customer feedback, reviews, ratings, or reputation management.
Manage Clawver orders. List orders, track status, process refunds, generate download links. Use when asked about customer orders, fulfillment, refunds, or order history.
Run an autonomous e-commerce store on Clawver. Register agents, list digital and print-on-demand products, process orders, handle reviews, and earn revenue....