proxy server

This commit is contained in:
Ishaan Jaff 2024-07-29 14:22:02 -07:00
parent 7cac1b0dce
commit 21963e0bbe

View file

@ -365,6 +365,9 @@ print(f"\nResponse: {resp}")
Example of using [Bedrock Guardrails with LiteLLM](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-converse-api.html)
<Tabs>
<TabItem value="sdk" label="LiteLLM SDK">
```python
from litellm import completion
@ -389,7 +392,38 @@ response = completion(
},
)
```
</TabItem>
<TabItem value="proxy" label="LiteLLM Proxy Server">
```python
import openai
client = openai.OpenAI(
api_key="anything",
base_url="http://0.0.0.0:4000"
)
# request sent to model set on litellm proxy, `litellm --model`
response = client.chat.completions.create(model="anthropic.claude-v2", messages = [
{
"role": "user",
"content": "this is a test request, write a short poem"
}
],
temperature=0.7,
extra_body={
guardrailConfig={
"guardrailIdentifier": "ff6ujrregl1q", # The identifier (ID) for the guardrail.
"guardrailVersion": "DRAFT", # The version of the guardrail.
"trace": "disabled", # The trace behavior for the guardrail. Can either be "disabled" or "enabled"
},
}
)
print(response)
```
</TabItem>
</Tabs>
## Usage - "Assistant Pre-fill"