
Using LiteLLM proxy with Strands Agents on Amazon Bedrock AgentCore
Configure a Strands Agents agent on Amazon Bedrock AgentCore Runtime to route all LLM calls through a LiteLLM proxy, with environment variables for connection details and VPC networking to solve the hairpin routing problem.
LiteLLM proxy gives your Strands Agents on Amazon Bedrock AgentCore a centralized model gateway that handles routing, key management, rate limiting, and cost tracking across multiple models and providers. Instead of calling Amazon Bedrock directly from each agent, you route all LLM traffic through a single proxy endpoint.
This post walks through configuring a Strands Agents agent deployed on Amazon Bedrock AgentCore Runtime to use a LiteLLM proxy instead of calling Amazon Bedrock directly. You'll also learn how to solve the VPC networking considerations that arise when your proxy and agent runtime share the same VPC.
Why LiteLLM proxy?
Direct Bedrock calls from each agent work, but a proxy layer gives you:
- Model aliasing: define aliases like
platform.researchthat map to specific models. Swap the underlying model without touching agent code.
- Centralized API keys: one place to manage provider credentials instead of distributing them across agents.
- Usage tracking and budgets: monitor token usage, set spending limits per team or project.
- Load balancing and fallbacks: route across multiple model deployments with automatic failover.
- Unified API: agents use a single OpenAI-compatible interface regardless of the backing provider.
Architecture

Figure 1: The Strands Agent runs in Amazon Bedrock AgentCore Runtime (private subnet, VPC mode). It connects to the LiteLLM proxy via an Application Load Balancer. The proxy uses IAM Roles to call Amazon Bedrock for model inference. Traffic from the AgentCore Runtime exits through the NAT gateway to reach the internet-facing ALB.
The Strands Agent running in Amazon Bedrock AgentCore Runtime connects to the LiteLLM proxy via HTTPS. The proxy then routes the request to Amazon Bedrock (or any other configured provider) using its own credentials.
Prerequisites
- An Amazon Bedrock AgentCore project scaffolded with the AgentCore CLI
- A LiteLLM proxy deployed and accessible (for example, on Amazon EKS with an Application Load Balancer)
- A LiteLLM API key and model alias configured on the proxy
- VPC networking configured for the AgentCore Runtime
Step 1: Configure the model loader
Replace the direct Amazon Bedrock model with
LiteLLMModel from Strands Agents. The connection details come from environment variables so you can change them without modifying code.# app/MyAgent/model/load.pyimport osfrom strands.models.litellm import LiteLLMModel
def load_model() -> LiteLLMModel: """Get LiteLLM model client pointing to the LiteLLM proxy.""" # Disable SSL verification if configured (needed for some internal proxies) if os.environ.get("LITELLM_SSL_VERIFY", "true").lower() == "false": import litellm litellm.ssl_verify = False
return LiteLLMModel( client_args={ "api_key": os.environ["LITELLM_API_KEY"], "api_base": os.environ["LITELLM_API_BASE"], "use_litellm_proxy": True, }, model_id=os.environ.get("LITELLM_MODEL_ID", "platform.research"), )Key points:
-
use_litellm_proxy: Truetells Strands to route through the proxy rather than call the provider directly.
-
model_iduses a proxy alias (for example,platform.research) that maps to a model likebedrock/global.anthropic.claude-opus-4-8.
- SSL verification can be disabled for internal proxies with self-signed certs.
Step 2: Add the LiteLLM dependency
Update
pyproject.toml to include the [litellm] extra:[project]dependencies = [ "bedrock-agentcore >= 1.9.1", "strands-agents[litellm] >= 1.13.0", "botocore[crt] >= 1.35.0", "mcp >= 1.19.0",]Step 3: Configure environment variables
Add the LiteLLM connection details to your
agentcore.json runtime configuration using the envVars array:{ "runtimes": [{ "name": "MyAgent", "build": "CodeZip", "entrypoint": "main.py", "codeLocation": "app/MyAgent/", "networkMode": "VPC", "networkConfig": { "subnets": ["subnet-xxxxx"], "securityGroups": ["sg-xxxxx"] }, "protocol": "HTTP", "envVars": [ { "name": "LITELLM_API_BASE", "value": "https://litellm.example.com/" }, { "name": "LITELLM_API_KEY", "value": "sk-your-key-here" }, { "name": "LITELLM_MODEL_ID", "value": "platform.research" }, { "name": "LITELLM_SSL_VERIFY", "value": "false" } ] }]}For local development, add the same variables to
agentcore/.env.local :LITELLM_API_BASE=https://litellm.example.com/LITELLM_API_KEY=sk-your-key-hereLITELLM_MODEL_ID=platform.researchLITELLM_SSL_VERIFY=falseImportant: The correct field isenvVars(an array of{ name, value }objects), notenvironment. The wrong format silently fails, and the variables won't reach your runtime.
Step 4: Deploy and test
agentcore deploy -yagentcore invoke "Tell me a joke" --streamTroubleshooting VPC connectivity
If your agent returns a connection error like
litellm.InternalServerError: Connection error , the runtime can't reach your proxy. This is a networking issue when both the Amazon Bedrock AgentCore Runtime can't reach the LiteLLM proxy.
Diagnosing the issue
Use
agentcore invoke --exec to run network commands directly in the runtime:SESSION_ID=$(uuidgen)
# Test connectivity to the proxyagentcore invoke --exec --session-id "$SESSION_ID" \ "curl -s -o /dev/null -w '%{http_code}\n' https://litellm.example.com/"
# If you get 000, it's a connectivity/timeout issue# Compare with a known-reachable endpointagentcore invoke --exec --session-id "$SESSION_ID" \ "curl -s -o /dev/null -w '%{http_code}\n' https://amazon.com"
Switching models
One of the key benefits of a proxy is that switching models requires zero code changes. Update the
LITELLM_MODEL_ID environment variable:{ "name": "LITELLM_MODEL_ID", "value": "claude-sonnet-4" }Redeploy and your agent uses the new model. The proxy resolves the alias to whatever backing model you've configured.
Conclusion
LiteLLM proxy with Strands Agents on Amazon Bedrock AgentCore gives you centralized model management without sacrificing the deployment speed of AgentCore Runtime. The key steps are:
- Replace
BedrockModelwithLiteLLMModelusinguse_litellm_proxy: True
- Externalize connection details to
envVarsinagentcore.json
- Ensure VPC connectivity: check NAT gateway IPs in the ALB security group for reachability.
- Use
agentcore invoke --execfor network troubleshooting directly in the runtime
To get started, scaffold a new AgentCore project with
agentcore create and follow the steps in this post. For more information about LiteLLM model configuration, refer to Strands Agents LiteLLM Provider .References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article