ExamplescriptbeginnerRunnablechat-lab
Introduction
Runnable example (beginner) for script.
Key Facts
- Level
- beginner
- Runtime
- Python
- Pattern
- Single-turn interaction with inspectable output
- Interaction
- Live sandbox • Script
- Updated
- 14 March 2026
Navigate this example
Library
Browse examplesReopen the wider library to compare adjacent patterns and linked learning paths.Interaction
Run sandbox nowTry the interaction directly in this example’s guided sandbox surface.Source
Open full sourceRead the real implementation, highlighted checkpoints, and runtime requirements.MCP
Call via MCPUse the same resource inside agents, deterministic exports, and MCP setup flows.
01-introduction.py
python
from agents import Agent, Runner
import nest_asyncio
nest_asyncio.apply()
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
print(result.final_output)