Welcome! In this tutorial you'll install OpenClaw AI, configure your API credentials and run your very first AI agent β all in under 10 minutes. No prior experience with AI frameworks is required; basic command-line familiarity is enough.
What you'll build
A simple "research assistant" agent that takes a topic, looks up information, and returns a concise summary. You'll be able to extend it later.
1. Prerequisites
- Python 3.10 or newer (or Node.js 18+ if you prefer JS)
- An OpenClaw API key β sign up on the official site to obtain one
- A terminal and your favourite text editor
2. Installation
OpenClaw ships as both a Python and a JavaScript package. Pick whichever fits your stack.
Python (recommended)
pip install openclaw
Node.js
npm install openclaw
Verify the installation:
openclaw --version
# openclaw 1.4.2
3. Configure your API key
OpenClaw reads your API key from the OPENCLAW_API_KEY environment variable. Set it once per shell session (or persist it in your shell profile):
export OPENCLAW_API_KEY="sk-your-key-here"
β οΈ Keep your key secret
Never commit API keys to Git. Use a .env file with .gitignore, or a secrets manager like Vault / Doppler.
4. Your first agent
Create a file hello_claw.py:
from openclaw import Agent
agent = Agent(
name="research-assistant",
model="openclaw-1",
instructions=(
"You are a research assistant. Given a topic, return a "
"concise summary in 3 bullet points."
),
)
result = agent.run("the history of the World Wide Web")
print(result.text)
Run it:
python hello_claw.py
# βΊ The World Wide Web was invented by Tim Berners-Lee in 1989β¦
# βΊ It was originally proposed as a way for physicists to share dataβ¦
# βΊ The first website went live in 1991 at CERNβ¦
5. What just happened?
Let's break down the four lines of agent code:
Agent(...)β instantiates a new agent.nameis its identifier;modelpicks the underlying LLM;instructionsis the system prompt.agent.run(topic)β synchronous call: send the prompt, wait for the full response.result.textβ the assistant's final message (string).- For streaming, use
async for chunk in agent.stream(topic)instead.
6. Next steps
- π Read the API Reference for all available methods.
- π§ Learn prompt engineering patterns that dramatically improve output quality.
- π€ Build multi-agent systems where agents collaborate.
- π When you're ready to ship, see the deployment guide.
Advertisement
Ad slot (in-article / responsive)
π You did it!
You've installed OpenClaw, configured credentials and run your first agent. Bookmark this site β we publish new tutorials every week.