Building a self-service LLM gateway with Amazon Bedrock and LiteLLM

In one sentence

This post explains how to build a self-service LLM gateway using Amazon Bedrock and LiteLLM on AWS Fargate to provide an OpenAI-compatible API with cost controls and observability.

Key points

  • Run LiteLLM proxy on AWS Fargate to provide developers with a unified, OpenAI-compatible API endpoint.
  • Use Amazon Bedrock Application Inference Profiles to achieve per-model quota isolation and fine-grained IAM access control.
  • Integrate Amazon RDS, ElastiCache, and Langfuse to support virtual key management, spend tracking, caching, and observability.
  • Developers can obtain API keys via a self-service portal to easily connect coding assistants like Claude Code, Continue, and Cursor.

In depth

An AI-written overview of the original article, not the article itself.

The AWS Machine Learning Blog details how to build a self-service LLM gateway using Amazon Bedrock Application Inference Profiles and LiteLLM on AWS Fargate. The architecture abstracts Amazon Bedrock behind an OpenAI-compatible API, allowing developers to connect AI coding assistants with minimal setup while giving platform, finance, and security teams centralized access control, cost attribution, and observability.

Core Architecture and Components

Requests from OpenAI-compatible clients such as Claude Code, Continue, and Cursor route through Amazon Route 53, Amazon CloudFront, and an Application Load Balancer to LiteLLM running on AWS Fargate. LiteLLM uses Amazon RDS (PostgreSQL) to store virtual keys and spend data, Amazon ElastiCache for Valkey for response caching and rate-limiting, and AWS Secrets Manager for credentials.

LiteLLM includes a self-service portal where operations engineers set spend policies and developers authenticate via corporate SSO to generate or rotate API keys. While the open source gateway is free for up to five users, the article notes that the self-service key issuance feature requires LiteLLM Enterprise.

Bedrock Inference Profiles and Routing

LiteLLM invokes Amazon Bedrock Application Inference Profiles, managed via AWS CDK, to provide per-model quota isolation and decouple gateway configuration from model versioning.

The post recommends Global cross-Region inference (CRIS) when policies allow, offering broader capacity and potential pricing benefits over Geographic CRIS. When configuring CDK, teams must reference the system-defined profile prefixed with global. and grant IAM permissions for both the inference profile and the underlying foundation models across Regions.

Cost Controls and Observability

To prevent unexpected charges from heavy usage, LiteLLM enforces rolling spend limits per API key, returning an HTTP 429 error when exceeded. Finance and engineering teams can track daily or per-user spend through built-in APIs and the Admin UI, while developers see remaining request and token limits in response headers.

For monitoring, the architecture pairs Langfuse for prompt-level telemetry and debugging with Amazon CloudWatch. Because extended thinking models can take minutes per request, the blog advises tracking requests per minute (RPM) and tokens per minute (TPM) rather than latency percentiles, setting CloudWatch alarms at 60 to 70 percent quota utilization.

Read originalOpens aws.amazon.com

This summary was generated by AI from the original article and may contain errors; the original is authoritative. Copyright belongs to the original author.

Recent stories from this source