From dbf4acc4ce315923232d2123976134efc0720848 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 9 Jul 2024 11:56:21 -0700 Subject: [PATCH] docs(image_generation.md): add proxy image gen example to docs --- docs/my-website/docs/audio_transcription.md | 2 +- docs/my-website/docs/image_generation.md | 71 ++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/my-website/docs/audio_transcription.md b/docs/my-website/docs/audio_transcription.md index 25eca6caa46..b4a1df01c42 100644 --- a/docs/my-website/docs/audio_transcription.md +++ b/docs/my-website/docs/audio_transcription.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# Audio Transcription +# Speech to Text Use this to loadbalance across Azure + OpenAI. diff --git a/docs/my-website/docs/image_generation.md b/docs/my-website/docs/image_generation.md index 10b5b5e68b3..5a7ef6f4f78 100644 --- a/docs/my-website/docs/image_generation.md +++ b/docs/my-website/docs/image_generation.md @@ -14,7 +14,76 @@ response = image_generation(prompt="A cute baby sea otter", model="dall-e-3") print(f"response: {response}") ``` -### Input Params for `litellm.image_generation()` +## Proxy Usage + +### Setup config.yaml + +```yaml +model_list: + - model_name: dall-e-2 ### RECEIVED MODEL NAME ### + litellm_params: # all params accepted by litellm.image_generation() + model: azure/dall-e-2 ### MODEL NAME sent to `litellm.image_generation()` ### + api_base: https://my-endpoint-europe-berri-992.openai.azure.com/ + api_key: "os.environ/AZURE_API_KEY_EU" # does os.getenv("AZURE_API_KEY_EU") + rpm: 6 # [OPTIONAL] Rate limit for this deployment: in requests per minute (rpm) + +``` + +### Start proxy + +```bash +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +### Test + + + + +```bash +curl -X POST 'http://0.0.0.0:4000/v1/images/generations' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Bearer sk-1234' \ +-D '{ + "model": "dall-e-2", + "prompt": "A cute baby sea otter", + "n": 1, + "size": "1024x1024" +}' +``` + + + + +```python +from openai import OpenAI +client = openai.OpenAI( + api_key="sk-1234", + base_url="http://0.0.0.0:4000" +) + + +image = client.images.generate( + prompt="A cute baby sea otter", + model="dall-e-3", +) + +print(image) +``` + + + +## Input Params for `litellm.image_generation()` + +:::info + +Any non-openai params, will be treated as provider-specific params, and sent in the request body as kwargs to the provider. + +[**See Reserved Params**](https://github.com/BerriAI/litellm/blob/2f5f85cb52f36448d1f8bbfbd3b8af8167d0c4c8/litellm/main.py#L4082) +::: + ### Required Fields - `prompt`: *string* - A text description of the desired image(s).