Skip to content
STIRUP

TECHNOLOGY INTELLIGENCE

Understand what's next.

Self-Service LLM Gateway Using Amazon Bedrock and LiteLLM

This implementation uses Amazon Bedrock Application Inference Profiles and LiteLLM on AWS Fargate to create an OpenAI-compatible API abstraction for Amazon Bedrock, with minimal developer configuration and budget control features.

Share
AI-generated conceptual illustration accompanying: Self-Service LLM Gateway Using Amazon Bedrock and LiteLLM
AI-generated editorial illustration of the article topic; not a photograph, product screenshot or measured result.

Implementation Overview and Configuration

In this implementation overview, the self-service LLM gateway is built using Amazon Bedrock Application Inference Profiles and LiteLLM running on AWS Fargate, enabling an OpenAI-compatible API abstraction for Amazon Bedrock (AWS Machine Learning). Developers only need to configure their tools with a minimal setup, including an API key, base URL, and model name (AWS Machine Learning). The LiteLLM gateway maps model names to specific Amazon Bedrock inference profile ARNs and enforces per-key spend limits, ensuring budget control (AWS Machine Learning). An example configuration includes setting the model name to claude-sonnet-4-20250514 and mapping it to an inference profile ARN (AWS Machine Learning). The AWS CloudFormation template defines the inference profile, granting LiteLLM's task role access to invoke it (AWS Machine Learning). Additionally, LiteLLM integrates with Langfuse for observability through logging callbacks, providing insights into model invocations without requiring changes to developer configurations (AWS Machine Learning). When a user exceeds their budget, LiteLLM returns an HTTP 429 status code with a message indicating the budget has been exceeded (AWS Machine Learning).

Security and Access Control

Security and access control are critical components when building a self-service LLM gateway using Amazon Bedrock and LiteLLM. Amazon Bedrock Application Inference Profiles allow the creation of named endpoints for specific models, enabling quota isolation and fine-grained IAM control (AWS Machine Learning). Access to these endpoints can be restricted by scoping permissions to the application-inference-profile ARN, ensuring that unauthorized attempts to invoke models result in access denied errors (AWS Machine Learning). The guidance also integrates Amazon Bedrock Guardrails, which provide security and compliance features that extend to all LLM providers, along with secure API key management and comprehensive access controls (aws-solutions-library-samples.github.io). Additionally, the architecture includes AWS Web Application Firewall (WAF) protection for the LiteLLM gateway proxy API endpoint, which is accessible via an Amazon Route 53 URL (aws-solutions-library-samples.github.io).

Observability and Monitoring

Observability and monitoring are critical components in building a self-service LLM gateway using Amazon Bedrock and LiteLLM. LiteLLM integrates with Langfuse through logging callbacks, providing visibility into model invocations without requiring changes to developer tool configurations (AWS Machine Learning). Amazon CloudWatch alarms can be configured for quota management, such as setting an alarm for ~60% of your account's TPM quota, with the exact limit depending on your model and account (AWS Machine Learning). Application logs from LiteLLM are stored in S3 buckets for audit and analysis purposes (docs.aws.amazon.com, github.com). Additionally, CloudWatch Logs provide comprehensive insights into both infrastructure and application levels of Amazon ECS and EKS clusters, enabling effective troubleshooting and analysis (docs.aws.amazon.com). These tools collectively support robust observability and monitoring for the AI gateway (aws-solutions-library-samples.github.io).

Infrastructure and Cost Management

When building a self-service LLM gateway with Amazon Bedrock and LiteLLM, infrastructure and cost management are critical considerations. LiteLLM's open-source AI Gateway component is suitable for small pilots but has limitations, as noted in AWS Machine Learning. For self-service key issuance, the Enterprise version of LiteLLM is required, according to AWS Machine Learning. To manage costs effectively, Amazon EKS and ECS allow multiple applications to share compute resources, improving utilization and reducing idle capacity, as stated in docs.aws.amazon.com. The total cost of the solution includes LLM provider costs, such as those from Amazon Bedrock and Anthropic, as outlined in github.com. Factors like the type and number of EC2 instances used to host the LiteLLM container can significantly impact scaling and cost, as mentioned in github.com. For further guidance, Amazon's Cost Optimization whitepaper is recommended, as noted in docs.aws.amazon.com.

Deployment and Integration with AWS Services

Deployment and Integration with AWS Services involves leveraging multiple Amazon services to build a secure and scalable self-service LLM gateway. Tenants and client applications access the LiteLLM gateway proxy API through the Amazon Route 53 URL endpoint or Amazon CloudFront distribution, which is protected against common web exploits and bots using AWS Web Application Firewall (WAF) [github.com]. The API/middleware integrates natively with Amazon Bedrock to enable features not supported by the LiteLLM Open source project [github.com]. LiteLLM also integrates with Amazon ElastiCache (Redis OSS), Amazon Relational Database Service (RDS), and AWS Secrets Manager services [github.com]. Additional features include an Amazon Bedrock Interface, support for Amazon Bedrock Managed Prompts, Chat History, and Okta Oauth 2.0 JWT Token Auth [aws-solutions-library-samples.github.io]. The gateway seamlessly integrates with Amazon Bedrock and other AWS services, offering additional optimizations and enhanced compatibility with the AWS ecosystem [aws-solutions-library-samples.github.io].

Sources and reporting notes

Based on published source material. No independent hands-on testing is claimed.

Read more