(docs) bedrock pass existing client to completion

This commit is contained in:
Zeeshan Hooda 2023-10-09 01:01:42 -06:00
parent 5f55b4a1ab
commit f735ca7e46
No known key found for this signature in database
GPG key ID: 915BD527A339A46A
2 changed files with 23 additions and 2 deletions

View file

@ -49,6 +49,27 @@ response = completion(
) )
``` ```
### Passing a BedrockClient as a parameter - Completion()
Pass an existing BedrockClient object to litellm.completion. Useful when using AWS SSO sessions or assumed role sessions.
```python
import boto3
from litellm import completion
bedrock = boto3.client(
service_name="bedrock-runtime",
region_name="us-east-1",
aws_access_key_id="",
aws_secret_access_key_id="",
aws_session_token="",
)
response = completion(
model="bedrock/anthropic.claude-instant-v1",
messages=[{ "content": "Hello, how are you?","role": "user"}],
aws_bedrock_client=bedrock
)
```
## Supported AWS Bedrock Models ## Supported AWS Bedrock Models
Here's an example of using a bedrock model with LiteLLM Here's an example of using a bedrock model with LiteLLM

View file

@ -276,8 +276,8 @@ def completion(
init_bedrock_client( init_bedrock_client(
aws_access_key_id=aws_access_key_id, aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key, aws_secret_access_key=aws_secret_access_key,
aws_region_name=aws_region_name aws_region_name=aws_region_name,
) ),
) )
model = model model = model