OpenClaw

2026.3.20 · active · verified Fri Apr 17

OpenClaw is an open-source Python library designed for agent orchestration, serving as a plugin for the CMDOP platform. It provides tools and a framework for building and deploying intelligent agents that can interact with the CMDOP ecosystem. Currently at version 2026.3.20, it follows a YYYY.MM.DD versioning scheme, indicating active and continuous development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an OpenClaw agent, define a simple tool using the `@tool` decorator, and run the agent asynchronously. It uses an environment variable for the API key for security. The agent will connect to the CMDOP platform and make its defined tools available.

import asyncio
import os
from openclaw.agent import Agent
from openclaw.config import OpenClawConfig
from openclaw.tools import tool

# Define a tool for the agent to use
@tool
def greet(name: str) -> str:
    """Greets the given name."""
    return f"Hello, {name}!"

async def main():
    # Configure OpenClaw agent
    # Obtain your API key from the CMDOP platform
    config = OpenClawConfig(
        api_key=os.environ.get("OPENCLAW_API_KEY", "sk-DUMMY_API_KEY"),
        agent_id="my-first-openclaw-agent"
    )

    # Initialize the agent with the configuration
    agent = Agent(config)

    print(f"OpenClaw Agent '{config.agent_id}' running...")
    # The agent.run() method is asynchronous and connects to the CMDOP platform
    await agent.run()
    print("Agent stopped.")

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("Agent interrupted and stopping.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →