|
4 | 4 | </h1>
|
5 | 5 |
|
6 | 6 | <h2>
|
7 |
| - Transform any function into a production API in 3 lines. Your code stays unchanged. |
| 7 | + Deploy your local AI agent to Bedrock AgentCore with zero infrastructure |
8 | 8 | </h2>
|
9 | 9 |
|
10 | 10 | <div align="center">
|
|
20 | 20 | <a href="https://github.com/aws/bedrock-agentcore-sdk-python">Python SDK</a>
|
21 | 21 | ◆ <a href="https://github.com/aws/bedrock-agentcore-starter-toolkit">Starter Toolkit</a>
|
22 | 22 | ◆ <a href="https://github.com/awslabs/amazon-bedrock-agentcore-samples">Samples</a>
|
| 23 | + ◆ <a href="https://discord.gg/bedrockagentcore-preview">Discord</a> |
23 | 24 | </p>
|
24 | 25 | </div>
|
25 | 26 |
|
26 |
| -Bedrock AgentCore SDK is a lightweight Python SDK that transforms any AI agent function into a production-ready HTTP API server. Just add 3 lines to your existing code. |
| 27 | +## 🚀 From Local Development to Bedrock AgentCore |
27 | 28 |
|
28 |
| -## ⚠️ Preview Status |
29 |
| - |
30 |
| -Bedrock AgentCore SDK is currently in public preview. APIs may change as we refine the SDK. |
31 |
| - |
32 |
| -## The 3-Line Transformation |
33 |
| - |
34 |
| -**Before** - Your existing function: |
35 | 29 | ```python
|
36 |
| -def invoke(payload): |
37 |
| - user_message = payload.get("prompt", "Hello") |
38 |
| - response = agent(user_message) |
39 |
| - return response |
40 |
| -``` |
41 |
| - |
42 |
| -**After** - Add 3 lines to make it an API: |
43 |
| -```python |
44 |
| -from bedrock_agentcore.runtime import BedrockAgentCoreApp # +1 |
45 |
| -app = BedrockAgentCoreApp() # +2 |
46 |
| - |
47 |
| -@app.entrypoint # +3 |
48 |
| -def invoke(payload): # ← Your function stays EXACTLY the same |
49 |
| - user_message = payload.get("prompt", "Hello") |
50 |
| - response = agent(user_message) |
51 |
| - return response |
52 |
| -``` |
| 30 | +# Your existing agent (any framework) |
| 31 | +from langgraph import StateGraph |
| 32 | +# or CrewAI, Autogen, custom logic - doesn't matter |
53 | 33 |
|
54 |
| -Your function is now a production-ready API server with health monitoring, streaming support, and AWS integration. |
| 34 | +def my_local_agent(query): |
| 35 | + # Your carefully crafted agent logic |
| 36 | + return agent.process(query) |
55 | 37 |
|
56 |
| -## Features |
57 |
| - |
58 |
| -- **Zero Code Changes**: Your existing function remains untouched |
59 |
| -- **Production Ready**: Automatic `/invocations` and `/ping` endpoints with health monitoring |
60 |
| -- **Streaming Support**: Native support for generators and async generators |
61 |
| -- **Async Task Tracking**: Built-in monitoring for long-running background tasks |
62 |
| -- **Framework Agnostic**: Works with any AI framework (Strands, LangChain, custom) |
63 |
| -- **AWS Optimized**: Ready for deployment to AWS infrastructure |
64 |
| - |
65 |
| -## Quick Start |
66 |
| - |
67 |
| -```bash |
68 |
| -pip install bedrock-agentcore |
69 |
| -``` |
70 |
| - |
71 |
| -```python |
72 |
| -# my_agent.py |
73 |
| -from strands import Agent # Or any AI framework |
74 |
| -from bedrock_agentcore.runtime import BedrockAgentCoreApp |
75 |
| - |
76 |
| -agent = Agent() |
| 38 | +# Deploy to Bedrock AgentCore |
| 39 | +from bedrock_agentcore import BedrockAgentCoreApp |
77 | 40 | app = BedrockAgentCoreApp()
|
78 | 41 |
|
79 |
| -@app.entrypoint |
80 |
| -def invoke(payload): |
81 |
| - """Your existing function - unchanged""" |
82 |
| - user_message = payload.get("prompt", "Hello") |
83 |
| - response = agent(user_message) |
84 |
| - return response |
| 42 | +@app.entrypoint |
| 43 | +def production_agent(request): |
| 44 | + return my_local_agent(request['query']) # Same logic, enterprise platform |
85 | 45 |
|
86 |
| -if __name__ == "__main__": |
87 |
| - app.run() # Starts server on http://localhost:8080 |
| 46 | +production_agent.run() # Ready to run on Bedrock AgentCore |
88 | 47 | ```
|
89 | 48 |
|
90 |
| -Test your API: |
91 |
| -```bash |
92 |
| -curl -X POST http://localhost:8080/invocations \ |
93 |
| - -H "Content-Type: application/json" \ |
94 |
| - -d '{"prompt": "Hello world!"}' |
95 |
| -``` |
| 49 | +**What you get with Bedrock AgentCore:** |
| 50 | +- ✅ **Keep your agent logic** - Works with LangGraph, CrewAI, Autogen, custom frameworks |
| 51 | +- ✅ **Zero infrastructure management** - No servers, containers, or scaling concerns |
| 52 | +- ✅ **Enterprise-grade platform** - Built-in auth, memory, observability, security |
| 53 | +- ✅ **Production-ready deployment** - Reliable, scalable, compliant hosting |
96 | 54 |
|
97 |
| -## Core Capabilities |
| 55 | +## ⚠️ Preview Status |
98 | 56 |
|
99 |
| -### Streaming Responses |
100 |
| -```python |
101 |
| -@app.entrypoint |
102 |
| -def invoke(payload): |
103 |
| - # Yields are automatically converted to Server-Sent Events |
104 |
| - for chunk in agent.stream(payload.get("prompt")): |
105 |
| - yield chunk |
106 |
| -``` |
| 57 | +Bedrock AgentCore SDK is currently in public preview. APIs may change as we refine the SDK. |
107 | 58 |
|
108 |
| -### Custom Health Checks |
109 |
| -```python |
110 |
| -@app.ping |
111 |
| -def health_check(): |
112 |
| - return PingStatus.HEALTHY if model_loaded else PingStatus.UNHEALTHY |
113 |
| -``` |
| 59 | +## 🛠️ Built for AI Developers |
114 | 60 |
|
115 |
| -### Async Task Tracking |
| 61 | +**Real-time Health Monitoring** |
116 | 62 | ```python
|
117 |
| -@app.async_task |
118 |
| -async def background_task(): |
119 |
| - # Automatically tracked for health monitoring |
120 |
| - await long_running_operation() |
121 |
| -``` |
| 63 | +@app.async_task # Automatically tracks background work |
| 64 | +async def process_documents(files): |
| 65 | + # Long-running AI processing |
| 66 | + return results |
122 | 67 |
|
123 |
| -### Request Context |
124 |
| -```python |
125 |
| -@app.entrypoint |
126 |
| -def invoke(payload, context: RequestContext): |
127 |
| - # Access session info and auth |
128 |
| - return agent(payload.get("prompt"), session_id=context.session_id) |
| 68 | +@app.ping # Custom health status |
| 69 | +def health_check(): |
| 70 | + return "HEALTHY" if all_services_up() else "HEALTHY_BUSY" |
129 | 71 | ```
|
130 | 72 |
|
131 |
| -## What's Created Automatically |
132 |
| - |
133 |
| -| Endpoint | Method | Purpose | |
134 |
| -|----------|--------|---------| |
135 |
| -| `/invocations` | POST | Calls your `invoke` function | |
136 |
| -| `/ping` | GET | Health checks for load balancers | |
137 |
| - |
138 |
| -BedrockAgentCoreApp handles: |
139 |
| -- HTTP request/response formatting |
140 |
| -- Content-type headers (`application/json` or `text/event-stream`) |
141 |
| -- Error handling and logging |
142 |
| -- Async task health monitoring |
143 |
| - |
144 |
| -## Deployment |
145 |
| - |
146 |
| -For production deployments, use [AWS CDK](https://aws.amazon.com/cdk/) for infrastructure as code. |
147 |
| - |
148 |
| -For quick prototyping and deployment tools, see the [Bedrock AgentCore Starter Toolkit](https://github.com/aws/bedrock-agentcore-starter-toolkit). |
149 |
| - |
150 |
| -## Contributing |
| 73 | +**Enterprise Platform Services** |
| 74 | +- 🧠 **Memory** - Persistent knowledge across sessions |
| 75 | +- 🔗 **Gateway** - Transform APIs into MCP tools |
| 76 | +- 💻 **Code Interpreter** - Secure sandboxed execution |
| 77 | +- 🌐 **Browser** - Cloud-based web automation |
| 78 | +- 📊 **Observability** - OpenTelemetry tracing |
| 79 | +- 🔐 **Identity** - AWS & third-party auth |
151 | 80 |
|
152 |
| -See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. |
| 81 | +## 🏗️ Deployment |
153 | 82 |
|
154 |
| -## License |
| 83 | +**Quick Start:** Use the [Bedrock AgentCore Starter Toolkit](https://github.com/aws/bedrock-agentcore-starter-toolkit) for rapid prototyping. |
155 | 84 |
|
156 |
| -Apache 2.0 License. See [LICENSE.txt](LICENSE.txt). |
| 85 | +**Production:** Deploy with [AWS CDK](https://aws.amazon.com/cdk/) for infrastructure as code. |
157 | 86 |
|
158 |
| -## Security |
| 87 | +## 📝 License & Contributing |
159 | 88 |
|
160 |
| -See [SECURITY.md](SECURITY.md) for reporting vulnerabilities. |
| 89 | +- **License:** Apache 2.0 - see [LICENSE.txt](LICENSE.txt) |
| 90 | +- **Contributing:** See [CONTRIBUTING.md](CONTRIBUTING.md) |
| 91 | +- **Security:** Report vulnerabilities via [SECURITY.md](SECURITY.md) |
0 commit comments