mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
parent
475aa06117
commit
7524aa386c
2 changed files with 5 additions and 46 deletions
|
|
@ -61,20 +61,6 @@ pip install google-cloud-iam
|
|||
```python
|
||||
import litellm
|
||||
from litellm import completion
|
||||
from litellm.caching.caching import Cache
|
||||
|
||||
# Using Redis Cache with GCP IAM Authentication
|
||||
litellm.cache = Cache(
|
||||
type="redis",
|
||||
host="10.128.0.2", # Your GCP Redis IP
|
||||
port=6379,
|
||||
gcp_service_account="projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com",
|
||||
gcp_ssl_ca_certs="./server-ca.pem", # Path to SSL CA certificate
|
||||
ssl=True,
|
||||
ssl_cert_reqs=None, # For self-signed certificates
|
||||
ssl_check_hostname=False, # For self-signed certificates
|
||||
)
|
||||
|
||||
# For Redis Cluster with GCP IAM
|
||||
from litellm.caching.redis_cluster_cache import RedisClusterCache
|
||||
|
||||
|
|
@ -84,7 +70,6 @@ litellm.cache = RedisClusterCache(
|
|||
{"host": "10.128.0.2", "port": 11008},
|
||||
],
|
||||
gcp_service_account="projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com",
|
||||
gcp_ssl_ca_certs="./server-ca.pem",
|
||||
ssl=True,
|
||||
ssl_cert_reqs=None,
|
||||
ssl_check_hostname=False,
|
||||
|
|
@ -111,8 +96,7 @@ You can also set these as environment variables:
|
|||
export REDIS_HOST="10.128.0.2"
|
||||
export REDIS_PORT="6379"
|
||||
export REDIS_GCP_SERVICE_ACCOUNT="projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com"
|
||||
export REDIS_GCP_SSL_CA_CERTS="./server-ca.pem"
|
||||
export REDIS_SSL="True"
|
||||
export REDIS_SSL="False"
|
||||
```
|
||||
|
||||
Then simply initialize:
|
||||
|
|
|
|||
|
|
@ -210,6 +210,10 @@ but we **don't** recommend using REDIS_URL in prod. We've noticed a performance
|
|||
|
||||
For GCP Memorystore Redis with IAM authentication, install the required dependency:
|
||||
|
||||
:::info
|
||||
IAM authentication for redis is only supported via GCP and only on Redis Clusters for now.
|
||||
:::
|
||||
|
||||
```shell
|
||||
pip install google-cloud-iam
|
||||
```
|
||||
|
|
@ -218,25 +222,6 @@ pip install google-cloud-iam
|
|||
|
||||
<TabItem value="gcp-iam-config" label="Set on config.yaml">
|
||||
|
||||
```yaml
|
||||
model_list:
|
||||
- model_name: gpt-3.5-turbo
|
||||
litellm_params:
|
||||
model: gpt-3.5-turbo
|
||||
|
||||
litellm_settings:
|
||||
cache: True
|
||||
cache_params:
|
||||
type: redis
|
||||
host: "10.128.0.2" # Your GCP Redis IP
|
||||
port: 6379
|
||||
gcp_service_account: "projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com"
|
||||
gcp_ssl_ca_certs: "./server-ca.pem" # Path to SSL CA certificate
|
||||
ssl: true
|
||||
ssl_cert_reqs: null # For self-signed certificates
|
||||
ssl_check_hostname: false # For self-signed certificates
|
||||
```
|
||||
|
||||
For Redis Cluster with GCP IAM:
|
||||
|
||||
```yaml
|
||||
|
|
@ -246,7 +231,6 @@ litellm_settings:
|
|||
type: redis
|
||||
redis_startup_nodes: [{"host": "10.128.0.2", "port": 6379}, {"host": "10.128.0.2", "port": 11008}]
|
||||
gcp_service_account: "projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com"
|
||||
gcp_ssl_ca_certs: "./server-ca.pem"
|
||||
ssl: true
|
||||
ssl_cert_reqs: null
|
||||
ssl_check_hostname: false
|
||||
|
|
@ -258,15 +242,6 @@ litellm_settings:
|
|||
|
||||
You can configure GCP IAM Redis authentication in your .env:
|
||||
|
||||
```env
|
||||
REDIS_HOST="10.128.0.2"
|
||||
REDIS_PORT="6379"
|
||||
REDIS_GCP_SERVICE_ACCOUNT="projects/-/serviceAccounts/your-sa@project.iam.gserviceaccount.com"
|
||||
REDIS_GCP_SSL_CA_CERTS="./server-ca.pem"
|
||||
REDIS_SSL="True"
|
||||
REDIS_SSL_CERT_REQS="None"
|
||||
REDIS_SSL_CHECK_HOSTNAME="False"
|
||||
```
|
||||
|
||||
For Redis Cluster:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue