AWS Bedrock
Amazon Bedrock
AWS's generative AI service platform. Provides various FMs such as Claude, Titan, and Llama through an API.
Amazon Bedrock
AWS's generative AI service platform. Provides various FMs such as Claude, Titan, and Llama through an API.
AWS Bedrock is a fully managed generative AI service provided by Amazon Web Services. By offering a variety of Foundation Models (FMs), such as Anthropic's Claude, Meta's Llama, Mistral AI, and Amazon's Titan, through a single API, it enables companies to develop applications that use the latest LLMs without building their own infrastructure.
It reached GA (general availability) in September 2023 and integrates tightly with existing AWS services. You can adopt generative AI naturally within the AWS ecosystem: access control with IAM, monitoring with CloudWatch, loading data from S3, and invocation from Lambda/ECS. Data is processed within AWS Regions, which makes regulatory compliance easier.
Bedrock's key features include Knowledge Bases (RAG automation), Agents (tool use and workflow automation), Guardrails (content filtering and safeguards), and Model Customization (fine-tuning). In particular, with Knowledge Bases you can vectorize documents in S3 and implement Retrieval-Augmented Generation (RAG) in just a few lines of code.
In practice, Bedrock is the fastest path for companies already using AWS infrastructure to adopt generative AI. With on-demand pricing you pay only for the tokens you use, and reserving with Provisioned Throughput guarantees throughput and can also reduce costs. For Claude models, an advantage is that you can receive AWS enterprise support, compared with using the Anthropic API directly.
import boto3
import json
# Bedrock Runtime 클라이언트 생성
bedrock = boto3.client(
service_name='bedrock-runtime',
region_name='us-east-1' # Bedrock 지원 리전
)
# Claude 3.5 Sonnet 호출
def invoke_claude(prompt: str) -> str:
response = bedrock.invoke_model(
modelId='anthropic.claude-3-5-sonnet-20241022-v2:0',
contentType='application/json',
accept='application/json',
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 4096,
"messages": [
{
"role": "user",
"content": prompt
}
]
})
)
result = json.loads(response['body'].read())
return result['content'][0]['text']
# 사용 예시
response = invoke_claude("Python으로 퀵소트 알고리즘을 구현해줘")
print(response)
# Amazon Titan Text 호출
def invoke_titan(prompt: str) -> str:
response = bedrock.invoke_model(
modelId='amazon.titan-text-premier-v1:0',
contentType='application/json',
accept='application/json',
body=json.dumps({
"inputText": prompt,
"textGenerationConfig": {
"maxTokenCount": 2048,
"temperature": 0.7,
"topP": 0.9
}
})
)
result = json.loads(response['body'].read())
return result['results'][0]['outputText']
# Llama 3 호출
def invoke_llama(prompt: str) -> str:
response = bedrock.invoke_model(
modelId='meta.llama3-70b-instruct-v1:0',
body=json.dumps({
"prompt": prompt,
"max_gen_len": 2048,
"temperature": 0.7
})
)
result = json.loads(response['body'].read())
return result['generation']
"If we go with Bedrock, we don't have to worry about model hosting infrastructure, and we can test Claude and Llama side by side to pick the model that fits our use case. With the Knowledge Base feature, RAG can be implemented right away using the documents in S3. Since data is processed only within AWS, the security team's review should also go more smoothly."
"We built an internal document search chatbot using Bedrock. We synced Confluence documents to the Knowledge Base and generated responses with Claude 3.5 Sonnet, and we applied Guardrails to prevent exposure of sensitive information. We invoked it from Lambda, exposed it through API Gateway, and integrated it with a Slack bot; the monthly cost was around $200."
"Bedrock costs are higher than expected, and the log analysis shows the prompts are too long. We need to cache the system prompt and reduce tokens by summarizing the conversation history. Also, if we build a model router that routes simple questions to Claude Haiku and sends complex ones to Sonnet, we can save about 70%."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Bedrock models can be used only after you explicitly request access in the AWS console. If you do not enable the model you want in the "Model access" menu, an AccessDeniedException occurs. Some models may take time to be approved.
Not all Bedrock models are available in every Region. The latest Claude versions are supported only in some Regions, such as us-east-1 and us-west-2. Be sure to check whether the Seoul Region (ap-northeast-2) is supported.
Apply input/output filtering with Guardrails, and log all invocations with CloudWatch Logs. Set up cost alarms, and consider Provisioned Throughput if steady traffic is expected. For sensitive data, enable the PII filter or mask it before invocation.