mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-13 05:06:09 +00:00
0f9996a4d0
* Addd v2/chat support for cohere * fix streaming * Use v2_transformation for logging passthrough: * Use v2_transformation for logging passthrough: * Add test for checking if document and citation_options is getting passed * Update the cohere model * Add cost tracking for vertex ai passthrough batch jobs * Add full passthrough support * refactor code according to the comments * Add passthrough handler * remove invalid params * Updated documentation * Updated documentation * Updated documentation * Correct the import * Add openai videos generation and retrieval support * add retrieval endpoint * Add docs * Add imports * remove orjson * remove double import * fix openai videos format * remove mock code * remove not required comments * Add tests * Add tests * Add other video endpoints * Fix cost calculation and transformation * Fixed mypy tests * remove not used imports * fix documentation for get batch req (#15742) * Add grounding info to responses API (#15737) * Add grounding info to responses API * fix lint errors * Use typed objects for annotations * Use typed objects for annotations * fix mypy error * Litellm fix json serialize alreting 2 (#15741) * fix json serializable error for alerts * Add test * fix mypt errors * fix mypt errors * Add Qwen3 imported model support for AWS Bedrock (#15783) * Add qwen imported model support * fix mypy errors * fix empty user message error (#15784) * fix typed dict for list * Add azure supported videos endpoint * fix mapped tests * add azure sora models to model map * Add OpenAI video generation and content retrieval support (#15745) * Add openai videos generation and retrieval support * add retrieval endpoint * Add docs * Add imports * remove orjson * remove double import * fix openai videos format * remove mock code * remove not required comments * Add tests * Add tests * Add other video endpoints * Fix cost calculation and transformation * Fixed mypy tests * remove not used imports * fix typed dict for list * fix mypy errors * move directory * make v2 chat default * Fix mypy tests * Fix mypy tests * Fix mypy tests * Fix mypy tests * Revert "Add Azure Video Generation Support with Sora Integration" * refactor videos repo * add test * Add azure openai videos support * Add azure openai videos support * Add router endpoint support for videos * fix mypy error * add azure models * fix mapped test * fix mypy error * Add proxy router test * Add proxy router test * remove deprecated model name from tests * fix import error * fix import error * Add gaurdrail integration in videos endpoint * Add logging support for videos endpoint * Add final documentation supporting videos integration * fix model name and document input * Update literals to avoid mypy errors * Remove unused imports and print statements * revert guardrail support for video generation and video remix * revert guardrail support for video generation and video remix * Fix failing mapped and llm translation tests
5.2 KiB
5.2 KiB
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
/batchPredictionJobs
LiteLLM supports Vertex AI batch prediction jobs through passthrough endpoints, allowing you to create and manage batch jobs directly through the proxy server.
Features
- Batch Job Creation: Create batch prediction jobs using Vertex AI models
- Cost Tracking: Automatic cost calculation and usage tracking for batch operations
- Status Monitoring: Track job status and retrieve results
- Model Support: Works with all supported Vertex AI models (Gemini, Text Embedding)
Cost Tracking Support
| Feature | Supported | Notes |
|---|---|---|
| Cost Tracking | ✅ | Automatic cost calculation for batch operations |
| Usage Monitoring | ✅ | Track token usage and costs across batch jobs |
| Logging | ✅ | Supported |
Quick Start
- Configure your model in the proxy configuration:
model_list:
- model_name: gemini-1.5-flash
litellm_params:
model: vertex_ai/gemini-1.5-flash
vertex_project: your-project-id
vertex_location: us-central1
vertex_credentials: path/to/service-account.json
- Create a batch job:
curl -X POST "http://localhost:4000/v1/projects/your-project/locations/us-central1/batchPredictionJobs" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"displayName": "my-batch-job",
"model": "projects/your-project/locations/us-central1/publishers/google/models/gemini-1.5-flash",
"inputConfig": {
"gcsSource": {
"uris": ["gs://my-bucket/input.jsonl"]
},
"instancesFormat": "jsonl"
},
"outputConfig": {
"gcsDestination": {
"outputUriPrefix": "gs://my-bucket/output/"
},
"predictionsFormat": "jsonl"
}
}'
- Monitor job status:
curl -X GET "http://localhost:4000/v1/projects/your-project/locations/us-central1/batchPredictionJobs/job-id" \
-H "Authorization: Bearer your-api-key"
Model Configuration
When configuring models for batch operations, use these naming conventions:
model_name: Base model name (e.g.,gemini-1.5-flash)model: Full LiteLLM identifier (e.g.,vertex_ai/gemini-1.5-flash)
Supported Models
gemini-1.5-flash/vertex_ai/gemini-1.5-flashgemini-1.5-pro/vertex_ai/gemini-1.5-progemini-2.0-flash/vertex_ai/gemini-2.0-flashgemini-2.0-pro/vertex_ai/gemini-2.0-pro
Advanced Usage
Batch Job with Custom Parameters
curl -X POST "http://localhost:4000/v1/projects/your-project/locations/us-central1/batchPredictionJobs" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"displayName": "advanced-batch-job",
"model": "projects/your-project/locations/us-central1/publishers/google/models/gemini-1.5-pro",
"inputConfig": {
"gcsSource": {
"uris": ["gs://my-bucket/advanced-input.jsonl"]
},
"instancesFormat": "jsonl"
},
"outputConfig": {
"gcsDestination": {
"outputUriPrefix": "gs://my-bucket/advanced-output/"
},
"predictionsFormat": "jsonl"
},
"labels": {
"environment": "production",
"team": "ml-engineering"
}
}'
List All Batch Jobs
curl -X GET "http://localhost:4000/v1/projects/your-project/locations/us-central1/batchPredictionJobs" \
-H "Authorization: Bearer your-api-key"
Cancel a Batch Job
curl -X POST "http://localhost:4000/v1/projects/your-project/locations/us-central1/batchPredictionJobs/job-id:cancel" \
-H "Authorization: Bearer your-api-key"
Cost Tracking Details
LiteLLM provides comprehensive cost tracking for Vertex AI batch operations:
- Token Usage: Tracks input and output tokens for each batch request
- Cost Calculation: Automatically calculates costs based on current Vertex AI pricing
- Usage Aggregation: Aggregates costs across all requests in a batch job
- Real-time Monitoring: Monitor costs as batch jobs progress
The cost tracking works seamlessly with the generateContent API and provides detailed insights into your batch processing expenses.
Error Handling
Common error scenarios and their solutions:
| Error | Description | Solution |
|---|---|---|
INVALID_ARGUMENT |
Invalid model or configuration | Verify model name and project settings |
PERMISSION_DENIED |
Insufficient permissions | Check Vertex AI IAM roles |
RESOURCE_EXHAUSTED |
Quota exceeded | Check Vertex AI quotas and limits |
NOT_FOUND |
Job or resource not found | Verify job ID and project configuration |
Best Practices
- Use appropriate batch sizes: Balance between processing efficiency and resource usage
- Monitor job status: Regularly check job status to handle failures promptly
- Set up alerts: Configure monitoring for job completion and failures
- Optimize costs: Use cost tracking to identify optimization opportunities
- Test with small batches: Validate your setup with small test batches first