Use AWS Bedrock & AI Services (Claude, Nova, Polly, Transcribe) with Your Existing OpenAI Code

Source: Dev.to | Dec 19, 2025 (UTC)

TL;DR

Use your existing OpenAI-compatible tools (OpenWebUI, n8n, Cline, Cursor) with AWS Bedrock’s 80+ models and AWS AI services (Polly, Transcribe). Just change the endpoint – no code changes needed. Deploy to your AWS account in 15 minutes with Terraform. Data stays in your AWS environment for HIPAA/GDPR compliance.

The Solution in 30 Seconds

from openai import OpenAI # Just change this line ↓ client = OpenAI(base_url="https://your-aws-api/v1", api_key="your-key") # Everything else stays the same ↓ response = client.chat.completions.create( model="anthropic.claude-sonnet-4-5-20250929-v1:0", # Claude 4.5 on Bedrock messages=[{"role": "user", "content": "Hello from AWS!"}] )

Enter fullscreen mode

Exit fullscreen mode

What this enables:

The Problem We Solved

Most modern AI tools are built for OpenAI’s API, but AWS Bedrock uses a completely different SDK. This forces you to choose between using familiar tools or switching to AWS for compliance/cost reasons and rewriting everything.

We ran into this while working with a customer who needed:

Our Approach: An OpenAI-Compatible Translation Layer

stdapi.ai is an API gateway that sits in your AWS account and translates OpenAI API calls to AWS services.

Key Features

OpenAI API Compatibility

Your existing code works without modifications:

from openai import OpenAI client = OpenAI( base_url="https://your-deployment.example.com/v1", api_key="your-api-key" ) # Chat completions response = client.chat.completions.create( model="amazon.nova-pro-v1:0", messages=[{"role": "user", "content": "Explain AWS Lambda"}] ) # Text-to-speech with Polly response = client.audio.speech.create( model="amazon.polly-neural", input="Welcome to the future of voice technology!" ) # Speech-to-text with Transcribe with open("meeting-recording.mp3", "rb") as audio_file: transcription = client.audio.transcriptions.create( model="amazon.transcribe", file=audio_file, response_format="json" ) # Image generation with Bedrock response = client.images.generate( model="stability.stable-image-ultra-v1:0", prompt="A serene mountain landscape at sunset" ) # Embeddings with Bedrock response = client.embeddings.create( model="cohere.embed-v4", input="Semantic search transforms how we find information" )

Enter fullscreen mode

Exit fullscreen mode

Multi-Region Access

Access models across multiple AWS Bedrock regions from a single endpoint. Different models are available in different regions. You can configure which regions to include based on your requirements. AWS Bedrock inference profiles handle automatic routing when needed.

Multi-Modal Capabilities

Process text, images, videos, and documents together in a single request. Supports HTTP URLs, S3 URLs (for direct access to your data), and base64 data URIs. Perfect for vision tasks, document analysis, and RAG applications.

Deployment

Deploy to your AWS account in 5-15 minutes using Terraform.

Sample configurations set up:

Get started: Sample Terraform configurations

Use Cases

Technical Details

How It Works:

  1. Converts OpenAI API format to Bedrock’s format
  2. Maps model IDs to appropriate AWS services and regions
  3. Provides unified access to models across configured AWS regions
  4. Converts Bedrock responses back to OpenAI format
  5. Supports streaming via Server-Sent Events (SSE)

Security:

Performance:

Open Source & Commercial Options

stdapi.ai is available as open source (AGPL-3.0) for experimentation and internal use.

For production deployments, we recommend the AWS Marketplace version, which includes:

The commercial license also removes AGPL obligations for proprietary applications.

Get Started

🏢 Recommended: AWS Marketplace (14-day free trial, production-ready)

🚀 Open source: GitHub (AGPL-3.0 for experimentation)

📦 Sample deployments: Terraform configurations

📚 Documentation: Full guides and API reference

Conclusion

This translation layer approach solves the AWS Bedrock compatibility gap while keeping everything AWS-native.

Key benefits:

We’d love to hear your feedback! Have you solved this problem differently? What challenges have you faced integrating Bedrock into your workflow?

What’s Next

We’re planning detailed tutorials on:

Want a specific tutorial? Drop a comment or open an issue on GitHub!

For further actions, you may consider blocking this person and/or reporting abuse

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *

Читайте також