Skip to main content
A weather assistant agent built with the AWS Strands library, demonstrating integration with Nebius Token Factory and external API calls using the http_request tool.

Features

  • Built with AWS Strands library
  • HTTP request tool for API integration
  • Weather forecasting via National Weather Service API
  • LiteLLM model integration
  • Clean, production-ready code structure

Prerequisites

Installation

1

Clone the repository

git clone https://github.com/Arindam200/awesome-ai-apps.git
cd starter_ai_agents/aws_strands_starter
2

Create virtual environment

# Create virtual environment with uv
uv venv

# Activate the virtual environment
source .venv/bin/activate
3

Install dependencies

# Install from pyproject.toml and uv.lock
uv sync
4

Configure environment

Create a .env file with your API key:
NEBIUS_API_KEY="your-nebius-api-key"

Implementation

Model Configuration

Set up the Strands agent with LiteLLM:
main.py
import os
from strands import Agent
from strands.models.litellm import LiteLLMModel
from strands_tools import http_request
from dotenv import load_dotenv

load_dotenv()

model = LiteLLMModel(
    client_args={
        "api_key": os.getenv("NEBIUS_API_KEY"),
    },
    model_id="nebius/deepseek-ai/DeepSeek-V3-0324",
    params={
        "max_tokens": 1000,
        "temperature": 0.7,
    },
)

System Prompt

Define the agent’s capabilities:
main.py
WEATHER_SYSTEM_PROMPT = """You are a weather assistant with HTTP capabilities. You can:

1. Make HTTP requests to the National Weather Service API
2. Process and display weather forecast data
3. Provide weather information for locations in the United States

When retrieving weather information:
1. First get the coordinates or grid information using 
   https://api.weather.gov/points/{latitude},{longitude} or 
   https://api.weather.gov/points/{zipcode}
2. Then use the returned forecast URL to get the actual forecast

When displaying responses:
- Format weather data in a human-readable way
- Highlight important information like temperature, precipitation, and alerts
- Handle errors appropriately
- Convert technical terms to user-friendly language

Always explain the weather conditions clearly and provide context for the forecast.
"""

Agent Setup

main.py
weather_agent = Agent(
    system_prompt=WEATHER_SYSTEM_PROMPT,
    tools=[http_request],  # Enable HTTP request tool
    model=model,
)

Running the Agent

main.py
response = weather_agent("Compare the temperature in New York and Chicago this weekend")
print(response)

Usage

Run the agent:
uv run main.py
The agent will:
  1. Create a weather assistant
  2. Make API calls to the National Weather Service
  3. Compare temperatures between cities
  4. Output formatted weather information

Example Queries

  • “What’s the weather in New York this weekend?”
  • “Compare the temperature in Seattle and Portland”
  • “Give me the forecast for San Francisco”
  • “What’s the weather like in Chicago today?”

Technical Details

AWS Strands Components

Agent

Core agent with system prompt and tools

LiteLLMModel

Model provider supporting multiple LLM backends

http_request

Built-in tool for making HTTP API calls

strands_tools

Collection of pre-built tools

HTTP Request Tool

The http_request tool allows the agent to:
  • Make GET, POST, PUT, DELETE requests
  • Handle JSON responses
  • Set custom headers
  • Parse and process API data
from strands_tools import http_request

# Agent automatically uses this tool when needed
response = weather_agent("Get weather for coordinates 40.7128, -74.0060")

Extending the Agent

Add Custom Tools

from strands import tool

@tool
def convert_temperature(celsius: float) -> dict:
    """Convert Celsius to Fahrenheit"""
    fahrenheit = (celsius * 9/5) + 32
    return {
        "celsius": celsius,
        "fahrenheit": fahrenheit
    }

weather_agent = Agent(
    system_prompt=WEATHER_SYSTEM_PROMPT,
    tools=[http_request, convert_temperature],
    model=model,
)

Customize Model Parameters

model = LiteLLMModel(
    client_args={"api_key": os.getenv("NEBIUS_API_KEY")},
    model_id="nebius/Qwen/Qwen3-235B-A22B",  # Different model
    params={
        "max_tokens": 2000,     # More tokens
        "temperature": 0.3,      # More deterministic
        "top_p": 0.9,
    },
)

Add Error Handling

try:
    response = weather_agent("What's the weather in InvalidCity?")
    print(response)
except Exception as e:
    print(f"Error: {e}")
    print("Please check the location and try again.")

Use Different APIs

API_SYSTEM_PROMPT = """You are an API assistant. You can make HTTP requests to:
- Weather APIs (weather.gov, openweathermap.org)
- News APIs (newsapi.org)
- Data APIs (various)

Always validate responses and handle errors gracefully.
"""

api_agent = Agent(
    system_prompt=API_SYSTEM_PROMPT,
    tools=[http_request],
    model=model,
)

AWS Strands Course

For a comprehensive guide to AWS Strands, check out the full course:

AWS Strands Course

8-lesson progressive course covering agents, sessions, MCP, multi-agent patterns, and more

Course Topics

  1. Basic agent with simple tools
  2. Session management and persistent conversations
  3. Structured output with Pydantic
  4. MCP agent with external tool integration
  5. Human-in-the-loop patterns
  6. Multi-agent systems (orchestrator, swarm, graph, workflow)
  7. Observability with OpenTelemetry and Langfuse
  8. Guardrails and safety measures

Best Practices

  • Be explicit about available capabilities
  • Provide clear instructions for API usage
  • Define expected output format
  • Include error handling guidance
  • Use built-in tools when available
  • Keep custom tools focused
  • Validate tool inputs
  • Handle API rate limits
  • Choose appropriate model size
  • Adjust temperature for use case
  • Set reasonable token limits
  • Test with different models

Environment Variables

VariableDescriptionRequired
NEBIUS_API_KEYYour Nebius API keyYes

Next Steps

AWS Strands Course

Complete 8-lesson course on AWS Strands

MCP Integration

Connect external services with MCP

Build docs developers (and LLMs) love