Skip to main content

Command Palette

Search for a command to run...

AWS Strands SDK Masterclass: Models and Model Providers

Updated
10 min read
AWS Strands SDK Masterclass: Models and Model Providers

Published: June 7, 2025

In our previous post, we introduced the AWS Strands Agents SDK and created our first simple agent. Now, let's dive deeper into one of the core components of any Strands agent: the model. The foundation model you choose determines your agent's reasoning capabilities, knowledge, and overall performance. In this post, we'll explore the various model providers supported by Strands and how to configure them for optimal results.

Understanding Models in Strands

In Strands, a model is the AI foundation that powers your agent's reasoning and natural language capabilities. Strands is designed to be model-agnostic, allowing you to use various foundation models from different providers. This flexibility enables you to choose the model that best fits your specific use case, budget, and performance requirements.

Default Model: Amazon Bedrock with Claude

By default, Strands agents use Amazon Bedrock as the model provider with Claude 3.7 Sonnet as the default model. This provides an excellent balance of reasoning capabilities, tool use, and cost-effectiveness for most applications.

from strands import Agent

# Create an agent with the default model (Claude 3.7 Sonnet on Bedrock)
agent = Agent()

# This is equivalent to:
agent = Agent(model="us.anthropic.claude-3-7-sonnet-20250219-v1:0")

response = agent(
"What is 1234 multiplied by 5678, what is the square root of 1444"
)

Response

Let me calculate these for you:

1) 1234 × 5678 = 7,006,652

2) Square root of 1444 = 38

Configuring Amazon Bedrock Models

For more control over your Bedrock model configuration, you can create a BedrockModel instance:

import boto3
from strands import Agent
from strands.models import BedrockModel

# Create a BedrockModel with custom configuration
bedrock_model = BedrockModel(
    model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
    region_name='us-west-2',
    temperature=0.3,  # Lower temperature for more deterministic outputs
    max_tokens=1024,  # Limit response length
    # Optional: custom Bedrock client
    client=boto3.client('bedrock-runtime', region_name='us-west-2')
)

# Create an agent with the custom model configuration
agent = Agent(model=bedrock_model)

response = agent(
"Convert 100°F to Celsius, and then convert 5 kilometers to miles."
)

Response

I'll convert these measurements for you:

1) Converting 100°F to Celsius:
   °C = (°F - 32) × 5/9
   °C = (100 - 32) × 5/9
   °C = 68 × 5/9
   °C = 37.78°C

2) Converting 5 kilometers to miles:
   1 kilometer = 0.621371 miles
   5 kilometers = 5 × 0.621371 miles
   5 kilometers = 3.11 miles

So 100°F equals 37.78°C, and 5 kilometers equals 3.11 miles.

Important Bedrock Configuration Notes

  1. Model Access: You must enable model access in Amazon Bedrock for the models you want to use. Follow the AWS documentation to enable access.

  2. Region Availability: Not all models are available in all AWS regions. Check the Bedrock documentation for model availability by region.

  3. IAM Permissions: Your AWS credentials must have appropriate permissions to access Bedrock models. The minimum policy should include:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": "*"
        }
    ]
}

Integrating with LiteLLM for Multiple Providers

LiteLLM is a unified interface for various LLM providers that allows you to interact with models from OpenAI, Azure, and many others. This is particularly useful if you want to use OpenAI models with Strands:

# First install the required package
pip install strands-agents[litellm]
from strands import Agent
from strands.models.litellm import LiteLLMModel


# Create a LiteLLM model for OpenAI
litellm_model = LiteLLMModel(
    client_args={
        "api_key": "sk-proj-DD-****",
    },
    model_id="gpt-4o",
    params={
        "temperature": 0.5,
        "max_tokens": 1024
    }
)

# Create an agent with the OpenAI model via LiteLLM
agent = Agent(model=litellm_model)

response = agent(
    "You're advising a startup with $10M funding, entering the AI productivity tools space. Given current trends, outline a go-to-market plan, suggest a pricing model, and identify key technical differentiators needed to compete with Notion AI and Microsoft Copilot."
)

Response

Entering the AI productivity tools space with a $10M funding is an exciting opportunity. Here's a detailed go-to-market plan, pricing model, and key technical differentiators to consider:

### Go-to-Market Plan

1. **Market Research and Positioning:**
   - **Identify Target Audience:** Focus on professionals, teams, and enterprises seeking enhanced productivity through AI. Identify specific sectors like tech, finance, and education that can benefit significantly.
   - **Competitive Analysis:** Study Notion AI and Microsoft Copilot to understand their strengths and weaknesses. Identify gaps and areas for differentiation.
   - **Unique Value Proposition (UVP):** Develop a compelling UVP that highlights how your tool improves productivity, integrates seamlessly with existing workflows, and offers unique features.

2. **Product Development and Testing:**
   - **MVP Launch:** Develop a Minimum Viable Product (MVP) with core features. Gather feedback from beta testers and iterate based on their input.
   - **AI Capabilities:** Ensure robust AI capabilities such as natural language processing, machine learning, and predictive analytics.

3. **Marketing and Promotion:**
   - **Content Marketing:** Create educational content, case studies, and webinars to demonstrate the tool's capabilities and benefits.
   - **Partnerships and Collaborations:** Partner with other tech companies, productivity platforms, and influencers to expand reach.
   - **Launch Campaigns:** Use social media, email marketing, and paid advertising to create buzz around the launch.

4. **Sales Strategy:**
   - **Freemium Model:** Offer a free version with basic features to attract users. Provide premium features in a paid version to convert free users.
   - **Direct Sales:** Develop a sales team to target enterprise clients and offer customized solutions.

5. **Customer Support and Feedback Loop:**
   - **Customer Service:** Provide excellent customer support to build trust and loyalty.
   - **Feedback Mechanism:** Implement a system for continuous feedback to improve the product.
...

5. **Scalability and Performance:**
   - Build a scalable architecture to support growing user numbers without compromising on performance.

By focusing on these strategies and differentiators, your startup can effectively compete with established players like Notion AI and Microsoft Copilot in the AI productivity tools space.

Running Local Models with Ollama

For development, testing, or privacy-sensitive applications, you might want to run models locally. Strands supports this through Ollama integration:

from strands import Agent
from strands.models.ollama import OllamaModel

# First install the required package
# pip install strands-agents[ollama]

# Create an Ollama model (requires Ollama running locally)
ollama_model = OllamaModel(
    host="http://localhost:11434",  # Ollama server address
    model_id="gemma3",  # Specify which model to use
    temperature=0.3,
)

# Create an agent with the local Ollama model
agent = Agent(model=ollama_model)

response = agent(
    "Explain the difference between supervised,unsupervised learning"
)

Response

Okay, let’s break down the differences between Supervised, Unsupervised, and Reinforcement Learning – they’re all approaches to training machine learning models, but they tackle problems in fundamentally different ways.

**1. Supervised Learning:**

* **Concept:** Think of it like learning with a teacher. You provide the algorithm with labeled data – meaning you give it both the *input* and the *correct output*.
* **Data:** Labeled data – examples with known answers. (e.g., images of cats and dogs labeled as “cat” or “dog”, customer data with purchase history labeled as “likely to buy” or “unlikely to buy”).
* **Goal:** The algorithm learns a mapping function that predicts the output based on the input.
* **Examples:**
    * **Image Classification:** Identifying objects in images.
    * **Spam Detection:** Classifying emails as spam or not spam.
    * **Predicting House Prices:** Based on features like size, location, etc.
* **Key Phrase:** “Learning *from* labeled data.”


**2. Unsupervised Learning:**

* **Concept:**  The algorithm is given *unlabeled* data and must discover patterns and structures on its own. It's like exploring a new territory without a map.
* **Data:** Unlabeled data – just the inputs.
* **Goal:** The algorithm identifies hidden patterns, clusters, or reduces the dimensionality of the data.
* **Examples:**
    * **Customer Segmentation:** Grouping customers based on their behavior.
    * **Anomaly Detection:** Identifying unusual data points (e.g., fraudulent transactions).
    * **Dimensionality Reduction:** Simplifying complex data by reducing the number of variables.

Model Selection Strategy

When choosing a model for your Strands agent, consider these factors:

  1. Reasoning Capabilities: More advanced models like Claude 3.7 Sonnet or GPT-4o provide better reasoning and tool use.

  2. Cost: More capable models typically cost more per token. Balance capability with budget.

  3. Latency: Local models may have lower latency but reduced capabilities.

  4. Token Context Window: Larger context windows allow for more complex interactions but may increase costs.

  5. Specialized Knowledge: Some models excel in specific domains (code, science, etc.).

Here's a decision flowchart to help you choose:

Implementing Model Fallbacks

For production applications, it's often wise to implement model fallbacks in case your primary model provider experiences issues:

from strands import Agent
from strands.models.ollama import OllamaModel
from strands.models import BedrockModel

# Step 1: Define the local Ollama model (preferred)
local_model = OllamaModel(
    host="http://localhost:11434",
    model_id="gemma3",  # Replace with your local model name
    temperature=0.3,
)

# Step 2: Define the fallback Bedrock model
bedrock_model = BedrockModel(
    model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
    region_name="us-east-1"
)

# Step 3: Attempt to use the local model first; fallback to Bedrock if it fails
try:
    # Try initializing the agent with the local model
    agent = Agent(model=local_model)
    print("Using local Ollama model")
except Exception as e:
    print(f"Local model failed: {e}")
    print("Falling back to Bedrock model")
    agent = Agent(model=bedrock_model)

response = agent(
    "Explain the difference between AWS SNS vs AWS SQS"
)

Response

Okay, let's break down the differences between AWS SNS (Simple Notification Service) and AWS SQS (Simple Queue Service). They're both core AWS services for decoupling and distributing messages, but they serve different purposes and have distinct characteristics.

**1. AWS SNS (Simple Notification Service)**

* **Purpose:** SNS is a **publish/subscribe messaging service**. It's designed for sending notifications to multiple subscribers. Think of it like a broadcast system.
* **How it Works:**
    * **Publishers:** Applications or services send messages to an SNS topic.
    * **Subscribers:**  These can be email addresses, SMS messages, HTTP/HTTPS endpoints, AWS Lambda functions, or even other AWS services.
    * **Routing:** SNS routes the message to all of its subscribers.
* **Key Features:**
    * **Fan-out:**  The core strength – easily send a single message to many recipients.
    * **Filtering:** Subscribers can filter messages based on attributes (key-value pairs) within the message. This allows you to target specific subscribers with specific content.
    * **Delivery Types:** Supports different delivery methods (email, SMS, HTTP/HTTPS).
    * **Scalability:**  Handles a massive number of messages and subscribers.
* **Use Cases:**
    * **Mobile App Notifications:** Sending push notifications to users.
    * **Emergency Alerts:** Broadcasting critical information during emergencies.
    * **Marketing Campaigns:** Sending promotional emails.
    * **System Alerts:** Notifying administrators of system issues.
**2. AWS SQS (Simple Queue Service)**

* **Purpose:** SQS is a **message queuing service**. It's designed for decoupling applications and ensuring reliable message delivery.
* **How it Works:**
...
Do you want me to delve deeper into a specific aspect, such as:

*   Configuration examples?
*   Cost considerations?
*   How they integrate with other AWS services (Lambda, API Gateway, etc.)?

Performance Comparison

To help you make an informed decision, here's a comparison of different models based on our testing with Strands agents:

ModelReasoningTool UseContext WindowRelative CostLatency
Claude 3.7 Sonnet (Bedrock)ExcellentExcellent200KMediumMedium
Claude 3.5 Sonnet (Bedrock)Very GoodVery Good200KLowLow
Claude 3 Opus (Bedrock)OutstandingOutstanding200KHighHigh
GPT-4o (via LiteLLM)ExcellentExcellent128KMedium-HighMedium
Local Gemma (via Ollama)FairFairVariesFreeLow

Conclusion

The model you choose for your Strands agent significantly impacts its capabilities, performance, and cost. Amazon Bedrock with Claude models provides an excellent default option, but Strands' flexibility allows you to use various model providers based on your specific requirements.

In our next post, we'll explore how to build custom tools for your Strands agents, enabling them to interact with external systems and perform specialized tasks.

Reference Notebook

https://github.com/dataopslabs-aws/masterclass-strands/blob/main/strands-blog-2-models.ipynb

Resources


This post is part of the AWS Strands SDK Masterclass series, where we explore building intelligent AI agents using AWS Strands Agents SDK.

481 views

Strands ADK Masterclass: From Basics to Production

Part 4 of 5

This 12-part series covers AWS Strands SDK from basics to advanced topics like custom tools and multi-agent systems, with code, diagrams, and real-world tips—equipping you to build intelligent, production-ready AI agents across domains.

Up next

AWS Strands SDK Masterclass: Introduction to Building AI Agents

Published: June 6, 2025 In today's rapidly evolving AI landscape, building intelligent agents that can reason, use tools, and solve complex problems has become a critical capability for developers. AWS has introduced the Strands Agents SDK, a powerfu...

More from this blog

D

DataOps Labs

77 posts

Stay updated on the latest in AI/ML, Cloud, DevOps, MLOps, Generative AI and cutting-edge techniques with this continuous learning free newsletters.