docs boto3 instructions

This commit is contained in:
Ishaan Jaffer 2025-10-16 16:34:56 -07:00
parent 79516563a9
commit bbf9d6a57b
3 changed files with 23 additions and 20 deletions

View file

@ -113,20 +113,22 @@ The proxy automatically distributes requests across both regions.
```python showLineNumbers
import boto3
import json
import os
# Set dummy AWS credentials (required by boto3, but not used by LiteLLM proxy)
os.environ['AWS_ACCESS_KEY_ID'] = 'dummy'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'dummy'
os.environ['AWS_BEARER_TOKEN_BEDROCK'] = "sk-1234" # your litellm proxy api key
# Point boto3 to the LiteLLM proxy
bedrock_runtime = boto3.client(
service_name='bedrock-runtime',
region_name='us-west-2',
endpoint_url='http://0.0.0.0:4000/bedrock'
)
def add_custom_headers(request, **kwargs):
request.headers.update({'litellm_user_api_key': 'Bearer sk-1234'})
bedrock_runtime.meta.events.register('before-send.*.*', add_custom_headers)
response = bedrock_runtime.converse(
modelId='my-bedrock-model',
modelId='my-bedrock-model', # Your model_name from config.yaml
messages=[
{
"role": "user",

View file

@ -109,20 +109,22 @@ The proxy automatically distributes requests across both regions.
```python showLineNumbers
import boto3
import json
import os
# Set dummy AWS credentials (required by boto3, but not used by LiteLLM proxy)
os.environ['AWS_ACCESS_KEY_ID'] = 'dummy'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'dummy'
os.environ['AWS_BEARER_TOKEN_BEDROCK'] = "sk-1234" # your litellm proxy api key
# Point boto3 to the LiteLLM proxy
bedrock_runtime = boto3.client(
service_name='bedrock-runtime',
region_name='us-west-2',
endpoint_url='http://0.0.0.0:4000/bedrock'
)
def add_custom_headers(request, **kwargs):
request.headers.update({'litellm_user_api_key': 'Bearer sk-1234'})
bedrock_runtime.meta.events.register('before-send.*.*', add_custom_headers)
response = bedrock_runtime.invoke_model(
modelId='my-bedrock-model',
modelId='my-bedrock-model', # Your model_name from config.yaml
contentType='application/json',
accept='application/json',
body=json.dumps({

View file

@ -255,21 +255,20 @@ You can also call the load-balanced endpoint using the boto3 SDK:
```python showLineNumbers
import boto3
import json
import os
# Set dummy AWS credentials (required by boto3, but not used by LiteLLM proxy)
os.environ['AWS_ACCESS_KEY_ID'] = 'dummy'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'dummy'
os.environ['AWS_BEARER_TOKEN_BEDROCK'] = "sk-1234" # your litellm proxy api key
# Point boto3 to the LiteLLM proxy
bedrock_runtime = boto3.client(
service_name='bedrock-runtime',
region_name='us-west-2', # Can be any region
region_name='us-west-2',
endpoint_url='http://0.0.0.0:4000/bedrock'
)
# Custom header for authentication
def add_custom_headers(request, **kwargs):
request.headers.update({'litellm_user_api_key': 'Bearer sk-1234'})
# Register the event to inject headers before sending request
bedrock_runtime.meta.events.register('before-send.*.*', add_custom_headers)
# Call the load-balanced model
response = bedrock_runtime.invoke_model(
modelId='my-claude-model', # Your model_name from config.yaml