Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

🚀 AI SDK HTTP Agent

An example of deploying an AI SDK agent to Amazon Bedrock Agent Core using HTTP protocol.

🛠️ Prerequisites

  • Node.js v22+
  • Docker for containerization
  • AWS CLI configured with Bedrock permissions
  • ECR Repository for storing your Docker image

🚀 Local Development

  1. Install dependencies

    npm install
  2. Set up AWS credentials

    # Option 1: AWS CLI
    aws configure
    
    # Option 2: Environment variables
    export AWS_ACCESS_KEY_ID=your_access_key
    export AWS_SECRET_ACCESS_KEY=your_secret_key
    export AWS_REGION=us-east-1
  3. Start development server

    npm run dev
  4. Test locally

    curl -X POST http://localhost:8080/invocations \
      -H "Content-Type: application/octet-stream" \
      -d '{"input": "Hello! What can you help me with?"}'

🐳 Docker Deployment

Step 1: Create ECR Repository

aws ecr create-repository --repository-name ai-agent --region us-east-1

Step 2: Build and Push Image

# Get login token
aws ecr get-login-password --region us-east-1 | \
  docker login --username AWS --password-stdin [account-id].dkr.ecr.us-east-1.amazonaws.com

# Build for ARM64 (Graviton processors)
docker build --platform linux/arm64 \
  -t [account-id].dkr.ecr.us-east-1.amazonaws.com/ai-agent:latest .

# Push to ECR
docker push [account-id].dkr.ecr.us-east-1.amazonaws.com/ai-agent:latest

Step 3: Deploy to Bedrock Agent Core

  1. Open Bedrock Console → Agent Core → Create Agent
  2. Configure Agent Runtime:
    • Image URI: [account-id].dkr.ecr.us-east-1.amazonaws.com/ai-agent:latest
  3. Set IAM Permissions for Bedrock model access
  4. Deploy and test in the Agent Sandbox

🧪 Testing Your Agent

Bedrock Agent Sandbox

Use the Bedrock console with this test payload:

{
  "input": "What are the key benefits of using AWS Bedrock Agent Core?"
}

🚨 Troubleshooting

Common Issues

"Unsupported Media Type" Error

  • Ensure Content-Type is application/octet-stream
  • Bedrock Agent Core sends requests in this format

Model Access Denied

  • Verify Bedrock model access in your AWS region
  • Check IAM permissions for bedrock:InvokeModel

Container Won't Start

  • Check Docker platform matches deployment target (linux/arm64)
  • Verify all dependencies are installed in production stage