Python Quickstart
This quickstart takes you to a first running agent: install the SDK, pick a model provider, run the agent, then give it a tool. Everything past that (streaming, memory, observability, deployment) has its own guide, linked from next steps.
Install the Strands Harness SDK
Section titled “Install the Strands Harness SDK”Make sure you have Python 3.10+ installed and a virtual environment activated. See the Python docs on virtual environments if you need to set one up. Then install the SDK:
pip install strands-agentsRun your first agent
Section titled “Run your first agent”Strands works with any major model provider. The model is one object you hand to the
agent, and the rest of your code is the same no matter which provider is behind it. The
tabs below cover the most common providers; pick the one you already have access to,
then create agent.py with the snippet from that tab:
Amazon Bedrock is the default provider, using Claude Sonnet 4.6 in the us-west-2
region, so no extra install or model object is needed.
from strands import Agent
# Bedrock is the default, so no model object is needed.agent = Agent()agent("What is an agent harness, in one sentence?")Give the SDK AWS credentials with permission to invoke the model, using one of:
- Bedrock API key: set the
AWS_BEARER_TOKEN_BEDROCKenvironment variable to a Bedrock API key. Quickest for local development. - AWS credentials:
aws configure, or theAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, and optionallyAWS_SESSION_TOKENenvironment variables - IAM roles: on AWS services like EC2, ECS, or Lambda
Enable access to the models you use in the Amazon Bedrock console, following the AWS documentation.
pip install 'strands-agents[anthropic]'export ANTHROPIC_API_KEY=<your key>from strands import Agentfrom strands.models.anthropic import AnthropicModel
# Reads ANTHROPIC_API_KEY from the environment.model = AnthropicModel(model_id="claude-sonnet-5", max_tokens=4096)agent = Agent(model=model)agent("What is an agent harness, in one sentence?")pip install 'strands-agents[openai]'export OPENAI_API_KEY=<your key>from strands import Agentfrom strands.models.openai import OpenAIModel
# Reads OPENAI_API_KEY from the environment.model = OpenAIModel(model_id="gpt-5.4")agent = Agent(model=model)agent("What is an agent harness, in one sentence?")pip install 'strands-agents[gemini]'export GEMINI_API_KEY=<your key>from strands import Agentfrom strands.models.gemini import GeminiModel
# Reads GEMINI_API_KEY from the environment.model = GeminiModel(model_id="gemini-2.5-flash")agent = Agent(model=model)agent("What is an agent harness, in one sentence?")Runs models locally on your machine. No API key or cloud account needed.
pip install 'strands-agents[ollama]'ollama serveollama pull llama3.1from strands import Agentfrom strands.models.ollama import OllamaModel
model = OllamaModel(host="http://localhost:11434", model_id="llama3.1")agent = Agent(model=model)agent("What is an agent harness, in one sentence?")Run it:
python -u agent.pyDon’t see your provider? Strands also supports LiteLLM, Mistral, SageMaker, Llama API, llama.cpp, Writer, OpenAI-compatible endpoints, and any model behind a custom provider you write. See all supported model providers.
Add tools to your agent
Section titled “Add tools to your agent”You now have a working agent loop, but the agent has nothing to act with. It can only answer from what the model already knows. Tools are what let an agent do things: read a file, call an API, run a command, or look something up.
A tool is a function the model can decide to call. Tools come from two places: Strands
ships vended tools for common jobs like editing files,
running shell commands, and making HTTP requests, and you can turn any Python function of
your own into a tool with the @tool decorator. You’ll use one of each.
Add this to the top of agent.py. It imports the file_editor vended tool and defines a
custom letter_counter tool. The docstring and type hints are what the model reads to
decide when to call the tool and what to pass it:
from strands import Agent, toolfrom strands.vended_tools import file_editor
@tooldef letter_counter(word: str, letter: str) -> int: """ Count occurrences of a specific letter in a word.
Args: word (str): The input word to search in letter (str): The specific letter to count
Returns: int: The number of occurrences of the letter in the word """ if len(letter) != 1: raise ValueError("The 'letter' parameter must be a single character")
return word.lower().count(letter.lower())Then replace the agent creation with this. Both tools go in the tools list, and the
prompt asks for something that needs each of them (keep your model line if you set one):
agent = Agent(tools=[letter_counter, file_editor])agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')model = AnthropicModel(model_id="claude-sonnet-5", max_tokens=4096)agent = Agent(model=model, tools=[letter_counter, file_editor])agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')model = OpenAIModel(model_id="gpt-5.4")agent = Agent(model=model, tools=[letter_counter, file_editor])agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')model = GeminiModel(model_id="gemini-2.5-flash")agent = Agent(model=model, tools=[letter_counter, file_editor])agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')model = OllamaModel(host="http://localhost:11434", model_id="llama3.1")agent = Agent(model=model, tools=[letter_counter, file_editor])agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')Run it again. The model works out that counting letters is what letter_counter is for
and that writing a file is what file_editor is for, calls both, and you end up with an
answer.txt in your working directory. You wrote one of those tools; the other came with
the SDK.
What just happened
Section titled “What just happened”The agent decides when to call a tool based on the request, loops until it has an answer, and streams the response to your console.
flowchart LR A[Input & Context] --> Loop
subgraph Loop[" "] direction TB B["Reasoning (LLM)"] --> C["Tool Selection"] C --> D["Tool Execution"] D --> B end
Loop --> E[Response]Every invocation returns an AgentResult
carrying the run’s messages, metrics, and traces, so you can see which tools the agent
called and why. The Agent Loop explains the cycle
above, and Observability covers reading
traces and metrics. To silence the streamed console output, pass callback_handler=None
to the Agent.
Connect your AI coding assistant
Section titled “Connect your AI coding assistant”Strands ships an MCP server that gives AI coding assistants in your IDE live access to the Strands documentation — search, section browsing, and on-demand fetching — so the code they generate follows current APIs. It helps you build, but it isn’t required to run an agent.
The server requires uv. Once uv is installed, add the server to your AI coding tool:
Add the following to ~/.kiro/settings/mcp.json:
{ "mcpServers": { "strands-agents": { "command": "uvx", "args": ["strands-agents-mcp-server"], "disabled": false, "autoApprove": ["search_docs", "fetch_doc"] } }}See the Kiro MCP documentation for more details.
Run the following command:
claude mcp add strands uvx strands-agents-mcp-serverSee the Claude Code MCP documentation for more details.
Add the following to ~/.cursor/mcp.json:
{ "mcpServers": { "strands-agents": { "command": "uvx", "args": ["strands-agents-mcp-server"] } }}See the Cursor MCP documentation for more details.
Add the following to ~/.codex/config.toml:
[mcp_servers.strands-agents]command = "uvx"args = ["strands-agents-mcp-server"]See the Codex MCP documentation for more details.
Add the following to your mcp.json file:
{ "servers": { "strands-agents": { "command": "uvx", "args": ["strands-agents-mcp-server"] } }}See the VS Code MCP documentation for more details.
The Strands MCP server works with 40+ applications that support MCP. The general configuration is:
- Command:
uvx - Args:
["strands-agents-mcp-server"]
Verify the connection with the MCP Inspector:
npx @modelcontextprotocol/inspector uvx strands-agents-mcp-serverNext Steps
Section titled “Next Steps”You have a running agent with a tool. From here:
- Vended Tools - file editing, shell, HTTP, and more, ready to drop into
tools - MCP Tools - connect to external tool servers
- Examples - agents for many use cases, from multi-agent systems to autonomous agents
- Model Providers - every supported provider and its options
- Agent Loop - how Strands agents work under the hood
- Context Management - keep long conversations inside the model’s context window
- Memory - give the agent long-term memory across sessions with memory stores
- State & Sessions - how agents keep context across a conversation or workflow
- Streaming - stream events to a UI with async iterators or callback handlers
- Multi-agent - orchestrate multiple agents as one system
- Observability & Evaluation - understand agent decisions and improve them with data
- Operating Agents in Production - take agents from development to production at scale