mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
Merge b82fe58f6c
into b82af5b826
This commit is contained in:
commit
1953d16b13
2 changed files with 150 additions and 0 deletions
149
docs/my-website/docs/completion/video.md
Normal file
149
docs/my-website/docs/completion/video.md
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
# Using Video Models
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
Example passing videos to a model
|
||||||
|
|
||||||
|
|
||||||
|
## Proxy Config setup
|
||||||
|
|
||||||
|
Admins can configure file storage settings and retention policies in their LiteLLM config:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
model_list:
|
||||||
|
- model_name: vertex_ai/*
|
||||||
|
litellm_params:
|
||||||
|
model: vertex_ai/*
|
||||||
|
- model_name: bedrock/*
|
||||||
|
litellm_params:
|
||||||
|
model: bedrock/*
|
||||||
|
|
||||||
|
|
||||||
|
files_settings:
|
||||||
|
# Configure storage providers and retention
|
||||||
|
- custom_llm_provider: azure
|
||||||
|
api_base: https://exampleopenaiendpoint-production.up.railway.app
|
||||||
|
api_key: fake-key
|
||||||
|
api_version: "2023-03-15-preview"
|
||||||
|
- custom_llm_provider: openai
|
||||||
|
api_key: os.environ/OPENAI_API_KEY
|
||||||
|
- custom_llm_provider: bedrock
|
||||||
|
api_key: os.environ/BEDROCK_API_KEY
|
||||||
|
api_base: https://bedrock.us-east-1.amazonaws.com
|
||||||
|
retention_period: 7
|
||||||
|
- custom_llm_provider: vertex_ai
|
||||||
|
bucket_name: my-vertex_ai-bucket
|
||||||
|
retention_period: 7
|
||||||
|
```
|
||||||
|
|
||||||
|
This configuration:
|
||||||
|
- Sets up storage providers (GCS and S3) with their retention policies
|
||||||
|
- Configures provider-specific file endpoints for Azure and OpenAI
|
||||||
|
|
||||||
|
## 1. Local File and process on Vertex + Bedrock
|
||||||
|
|
||||||
|
When uploading a local file, the process follows these steps:
|
||||||
|
|
||||||
|
1. Client makes a POST request to `/files` endpoint with the local file
|
||||||
|
2. Client MUST specify required storage custom_llm_provider(s) based on intended model usage
|
||||||
|
3. LiteLLM uploads the file to specified custom_llm_provider(s)
|
||||||
|
4. A file ID is returned to the client
|
||||||
|
5. Files have a 7-day retention policy (configured by admin)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# custom_llm_provider is required
|
||||||
|
curl https://api.litellm.ai/v1/files \
|
||||||
|
-H "Authorization: Bearer sk-1234" \
|
||||||
|
-F purpose="fine-tune" \
|
||||||
|
-F file="@mydata.jsonl" \
|
||||||
|
-F custom_llm_provider='["vertex_ai"]' # Required: specify ["vertex_ai"], ["bedrock"], or ["vertex_ai", "bedrock"]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
After uploading, you can use the file_id in a /chat/completions request:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl "https://api.litellm.ai/v1/chat/completions" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer sk-1234" \
|
||||||
|
-d '{
|
||||||
|
"model": "bedrock/amazon.nova-pro-v1:0",
|
||||||
|
"input": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "input_file",
|
||||||
|
"file_id": "file-6F2ksmvXxt4VdoqmHRw6kL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_text",
|
||||||
|
"text": "What is happening in this video?"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Existing file in S3 and process on Vertex + Bedrock
|
||||||
|
|
||||||
|
For files already in S3, you can avoid downloading and re-uploading by using a presigned URL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# custom_llm_provider is required
|
||||||
|
curl -X POST "https://api.litellm.ai/files" \
|
||||||
|
-H "Authorization: Bearer sk-1234" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"source": "https://your-bucket.s3.amazonaws.com/path/to/mydata.jsonl?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...",
|
||||||
|
"custom_llm_provider": ["vertex_ai"] # Required: specify target custom_llm_provider
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
This performs a direct copy from the S3 presigned URL to the specified custom_llm_provider(s), which is more efficient than downloading and re-uploading.
|
||||||
|
|
||||||
|
After the S3 file is copied, you can use the returned file_id in your /chat/completions request:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl "https://api.litellm.ai/v1/chat/completions" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer sk-1234" \
|
||||||
|
-d '{
|
||||||
|
"model": "vertex_ai/gemini-pro-vision",
|
||||||
|
"input": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "input_file",
|
||||||
|
"file_id": "file-8H3jsmwYyt6WepqnKRw9mN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_text",
|
||||||
|
"text": "Describe the main events in this video"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
**Storage Location Selection**:
|
||||||
|
- You MUST specify custom_llm_provider based on your model requirements
|
||||||
|
- For Vertex AI models, specify `["vertex_ai"]`
|
||||||
|
- For Bedrock models, specify `["bedrock"]`
|
||||||
|
- For fallback scenarios, specify both `["vertex_ai", "bedrock"]`
|
||||||
|
- Avoid unnecessary copies by selecting only required destinations
|
||||||
|
## Model Compatibility
|
||||||
|
|
||||||
|
This file handling approach is compatible with various model backends:
|
||||||
|
- Vertex AI
|
||||||
|
- AWS Bedrock
|
||||||
|
- vLLM (for video processing, using their multimodal input format)
|
||||||
|
|
|
@ -260,6 +260,7 @@ const sidebars = {
|
||||||
"completion/web_search",
|
"completion/web_search",
|
||||||
"completion/document_understanding",
|
"completion/document_understanding",
|
||||||
"completion/vision",
|
"completion/vision",
|
||||||
|
"completion/video",
|
||||||
"completion/json_mode",
|
"completion/json_mode",
|
||||||
"reasoning_content",
|
"reasoning_content",
|
||||||
"completion/prompt_caching",
|
"completion/prompt_caching",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue