AI Cloud Architect

Building custom model provider for Strands Agents with LLMs hosted on SageMaker AI endpoints

AWSHow-to by Dan FergusonAWS Artificial Intelligence Blog

This post demonstrates how to build custom model parsers for Strands agents when working with LLMs hosted on SageMaker that don’t natively support the Bedrock Messages API format. We’ll walk through deploying Llama 3.1 with SGLang on SageMaker using awslabs/ml-container-creator, then implementing a custom parser to integrate it with Strands agents.

Read the original (opens the source's page in a new tab)

AI: Summary

What it is

Shows how to write a custom model provider in Strands Agents so it can call a Llama 3.1 model served by SGLang on a SageMaker AI endpoint that returns OpenAI-style responses.

Who it is for

Teams hosting open models on SageMaker AI that want Strands agents to call them without Bedrock Messages API support.

Key points

  • Default SageMakerAIModel expects the Bedrock Messages format and fails on OpenAI-style responses (TypeError).
  • Walkthrough uses awslabs/ml-container-creator to build the BYOC container and deploy to a real-time endpoint in us-east-1.
  • Example uses ml.g6.12xlarge GPU instance; endpoint takes about 10-15 minutes to reach InService.

Timeline

Posts about Strands Agents, oldest first.

  1. PreviewAnnouncing TypeScript support in Strands Agents (preview) and more · AWS · Announcement
  2. How-toCustomize agent workflows with advanced orchestration techniques using Strands Agents · AWS · How-to
  3. This postBuilding custom model provider for Strands Agents with LLMs hosted on SageMaker AI endpoints
  4. How-toEvaluating AI agents for production: A practical guide to Strands Evals · AWS · How-to
  5. How-toBuilding web search-enabled agents with Strands and Exa · AWS · How-to
  6. What it explainsAnnouncing OpenAI-compatible API support for Amazon SageMaker AI endpoints · AWS · AnnouncementAlso published by What's New with AWS
  7. Customer storyHow Rescale built an AI triage agent with Strands Agents and AI-DLC · AWS · Customer story

Go deeper