Skip to content

Quickstart

1. Install

Python 3.8 or newer. Plain pip works:

pip install agentplaykit

We recommend a virtual environment, so AgentPlay and its dependencies stay separate:

python -m venv .venv
.venv\Scripts\activate
pip install agentplaykit
python3 -m venv .venv
source .venv/bin/activate
pip install agentplaykit

'agentplaykit' is not recognized as a command

The folder pip put the command in is not on your PATH, usually because the virtual environment is not active (your prompt should start with (.venv)). Either activate it, or run every command through Python instead: python -m agentplaykit play.

In PowerShell, if activation says running scripts is disabled, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once, then activate again.

2. Run the demo

agentplaykit play
demo: Built-in demo, a perfect player (x) against a random one (o). No API key needed.
finished: x wins in 5 steps, cost $0.0000 -> runs/tic-tac-toe-demo-7.jsonl

Everything that happened is in runs/tic-tac-toe-demo-7.jsonl, one JSON event per line:

head -3 runs/tic-tac-toe-demo-7.jsonl

3. Write your own scenario

A scenario is one YAML file. Save this as my-game.yaml:

agentplay: 1
name: my-game
seed: 7
world: {use: tic-tac-toe}
agents:
  - {id: x, use: scripted/minimax}
  - {id: o, use: scripted/random}
agentplaykit check my-game.yaml     # finds mistakes without running anything
agentplaykit play my-game.yaml

4. Swap in a real model

Change one line. With Ollama running locally (free, no key):

  - {id: x, use: ollama, config: {model: "llama3.2"}}

Or a hosted service, with its key in the usual environment variable (here OPENROUTER_API_KEY):

  - {id: x, use: openrouter, config: {model: "<provider>/<model>"}}

See Real AI models for every option.

5. Let agents talk

agentplaykit play examples/tic-tac-toe-chat/scenario.yaml

6. Watch the replay

agentplaykit view runs/tic-tac-toe-demo-7.jsonl

Step through the game in your browser, or watch the next one live: agentplaykit play examples/tic-tac-toe-chat/scenario.yaml --live. See Watch and replay.

7. Run many games and compare

agentplaykit play examples/treasure/scenario.yaml --runs 20

To rank several agents against each other, run a tournament: every agent plays every other on both sides, and you get a leaderboard with ratings.

agentplaykit play examples/arena/scenario.yaml

See Compare agents.

With Docker installed, agents can also do real tasks in a locked-down container: agentplaykit play examples/hello-sandbox/scenario.yaml. See Sandbox tasks.

Next: write a world or write an agent.