기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
빠른 시작
이 섹션에서는 몇 분 내에 Amazon Bedrock을 시작하는 방법을 보여줍니다. OpenAI 호환 APIs Responses API 및 Chat Completions API와 Invoke 및 Converse API를 사용하여 추론 요청을 실행하는 방법을 보여줍니다. 전체 API 목록은 빌드 섹션을 참조하세요. APIs
1단계 - AWS 계정: AWS 계정이 이미 있는 경우이 단계를 건너뛰고 2단계로 이동합니다. AWS를 처음 사용하는 경우 AWS 계정에 가입하고 지침을 따릅니다.
2단계 - API 키: AWS 계정이 있으면 장기 API 키를 생성하여 Amazon Bedrock에 대한 요청을 인증할 수 있습니다. 이렇게 하려면 AWS 콘솔에서 Amazon Bedrock 서비스로 이동하여 장기 키를 생성합니다. 자세한 내용은 빌드 장의 API 키 섹션을 참조하세요.
3단계 - SDK 가져오기:이 시작 안내서를 사용하려면 Python이 이미 설치되어 있어야 합니다. 그런 다음 사용 중인 APIs에 따라 관련 소프트웨어를 설치합니다.
- Responses/Chat Completions API
-
pip install boto3 openai
- Invoke/Converse API
-
pip install boto3
4단계 - 환경 변수 설정: 인증에 API 키를 사용하도록 환경을 구성합니다.
- Responses/Chat Completions API
-
OPENAI_API_KEY="<provide your long term key>"
OPENAI_BASE_URL="https://bedrock-mantle.<your-region>.api.aws/v1"
- Invoke/Converse API
-
AWS_BEARER_TOKEN_BEDROCK="<provide your long term key>"
5단계 - 첫 번째 추론 요청 실행: Amazon Bedrock은 100개 이상의 파운데이션 모델을 지원합니다. 모델을 선택한 다음 다음 Python 코드를 사용하여 첫 번째 추론 요청을 실행합니다. 파일을 로 저장 bedrock-first-request.py
- Responses API
-
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="openai.gpt-oss-120b",
input="Can you explain the features of Amazon Bedrock?"
)
print(response)
- Chat Completions API
-
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="openai.gpt-oss-120b",
messages=[{"role": "user", "content": "Can you explain the features of Amazon Bedrock?"}]
)
print(response)
- Invoke API
-
import json
import boto3
client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.invoke_model(
modelId='anthropic.claude-opus-4-6-v1',
body=json.dumps({
'anthropic_version': 'bedrock-2023-05-31',
'messages': [{ 'role': 'user', 'content': 'Can you explain the features of Amazon Bedrock?'}],
'max_tokens': 1024
})
)
print(json.loads(response['body'].read()))
- Converse API
-
import boto3
client = boto3.client('bedrock-runtime', region_name='us-east-1')
response = client.converse(
modelId='anthropic.claude-opus-4-6-v1',
messages=[
{
'role': 'user',
'content': [{'text': 'Can you explain the features of Amazon Bedrock?'}]
}
]
)
print(response)
명령을 사용하여 Python으로 코드를 실행합니다.
python3 bedrock-first-request.py
추론 요청의 출력이 표시됩니다.
다른 APIs 및 엔드포인트 사용에 대한 자세한 내용은 섹션을 참조하세요빌드.