The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Vector store files Stable Release (#16643)
Sameer Kankutea2e3b942dc12
diff --git a/docs/my-website/docs/providers/fal_ai.md b/docs/my-website/docs/providers/fal_ai.mdindex e50ef919da0..da0fd19123b 100644--- a/docs/my-website/docs/providers/fal_ai.md+++ b/docs/my-website/docs/providers/fal_ai.md@@ -31,10 +31,14 @@ Get your API key from [fal.ai](https://fal.ai/).| Model Name | Description | Documentation ||------------|-------------|---------------|+| `fal_ai/fal-ai/flux-pro/v1.1` | FLUX Pro v1.1 - Balanced speed and quality | [Docs ↗](https://fal.ai/models/fal-ai/flux-pro/v1.1) || `fal_ai/flux/schnell` | Flux Schnell - Low-latency generation with `image_size` support | [Docs ↗](https://fal.ai/models/fal-ai/flux/schnell) |+| `fal_ai/fal-ai/bytedance/seedream/v3/text-to-image` | ByteDance Seedream v3 - Text-to-image with `image_size` control | [Docs ↗](https://fal.ai/models/fal-ai/bytedance/seedream/v3/text-to-image) |+| `fal_ai/fal-ai/bytedance/dreamina/v3.1/text-to-image` | ByteDance Dreamina v3.1 - Text-to-image with `image_size` control | [Docs ↗](https://fal.ai/models/fal-ai/bytedance/dreamina/v3.1/text-to-image) || `fal_ai/fal-ai/flux-pro/v1.1-ultra` | FLUX Pro v1.1 Ultra - High-quality image generation | [Docs ↗](https://fal.ai/models/fal-ai/flux-pro/v1.1-ultra) || `fal_ai/fal-ai/imagen4/preview` | Google's Imagen 4 - Highest quality model | [Docs ↗](https://fal.ai/models/fal-ai/imagen4/preview) || `fal_ai/fal-ai/recraft/v3/text-to-image` | Recraft v3 - Multiple style options | [Docs ↗](https://fal.ai/models/fal-ai/recraft/v3/text-to-image) |+| `fal_ai/fal-ai/ideogram/v3` | Ideogram v3 - Lettering-first creative model (Balanced: $0.06/image) | [Docs ↗](https://fal.ai/models/fal-ai/ideogram/v3) || `fal_ai/fal-ai/stable-diffusion-v35-medium` | Stable Diffusion v3.5 Medium | [Docs ↗](https://fal.ai/models/fal-ai/stable-diffusion-v35-medium) || `fal_ai/bria/text-to-image/3.2` | Bria 3.2 - Commercial-grade generation | [Docs ↗](https://fal.ai/models/bria/text-to-image/3.2) |diff --git a/docs/my-website/docs/vector_store_files.md b/docs/my-website/docs/vector_store_files.mdnew file mode 100644index 00000000000..d5544f34994--- /dev/null+++ b/docs/my-website/docs/vector_store_files.md@@ -0,0 +1,120 @@+# /vector_stores/{vector_store_id}/files++Vector store files represent the individual files that live inside a vector store.++| Feature | Supported |+|---------|-----------|+| Logging | ✅ (full request/response logging) |+| Supported Providers | `openai` |+++## Supported operations++| Operation | Description | OpenAI Python Client | LiteLLM Proxy |+|-----------|-------------|----------------------|---------------|+| Create vector store file | Attach a file to a vector store with optional chunking overrides | ✅ | ✅ |+| List vector store files | Paginated listing with filters | ✅ | ✅ |+| Retrieve vector store file | Fetch metadata for a single file | ✅ | ✅ |+| Delete vector store file | Remove a file from a store (file object persists) | ✅ | ✅ |+| Retrieve vector store file content | Stream processed chunks | ❌ | ✅ |+| Update vector store file attributes | Patch custom attributes | ❌ | ✅ |++:::note+Vector store support currently works **only with OpenAI vector stores and OpenAI-uploaded file IDs**.+:::+++## Create vector store file++`POST http://localhost:4000/v1/vector_stores/{vector_store_id}/files`++```python+from openai import OpenAI++client = OpenAI(+ base_url="http://localhost:4000", # LiteLLM proxy or OpenAI base+ api_key="sk-1234"+)++vector_store_file = client.vector_stores.files.create(+ vector_store_id="vs_69172088a18c8191ab3e2621aa87d1ee",+ file_id="file-NDbEDJTfqVh7S4Ugi3CGYw",+ chunking_strategy={+ "type": "static",+ "static": {+ "max_chunk_size_tokens": 800,+ "chunk_overlap_tokens": 400,+ },+ },+)++print(vector_store_file)+```++## List vector store files++`GET http://localhost:4000/v1/vector_stores/{vector_store_id}/files`++Parameters:++- `vector_store_id` (path, required)+- `after` / `before` (query, optional) – pagination cursors+- `filter` (query, optional) – `in_progress`, `completed`, `failed`, `cancelled`+- `limit` (query, optional, default `20`, range `1-100`)+- `order` (query, optional, default `desc`)++```python+vector_store_files = client.vector_stores.files.list(+ vector_store_id="vs_abc123"+)+print(vector_store_files)+```++## Retrieve vector store file++`GET http://localhost:4000/v1/vector_stores/{vector_store_id}/files/{file_id}`++```python+vector_store_file = client.vector_stores.files.retrieve(+ vector_store_id="vs_abc123",+ file_id="file-abc123"+)+print(vector_store_file)+```++## Delete vector store file++`DELETE http://localhost:4000/v1/vector_stores/{vector_store_id}/files/{file_id}`++```python+deleted_vector_store_file = client.vector_stores.files.delete(+ vector_store_id="vs_abc123",+ file_id="file-abc123"+)+print(deleted_vector_store_file)+```++## Proxy-only endpoints++When you need raw content chunks or attribute updates, call the LiteLLM Proxy directly.++### Retrieve file content++```bash+curl -X GET "http://localhost:4000/v1/vector_stores/{vector_store_id}/files/{file_id}/content" \+ -H "Authorization: Bearer sk-1234"+```++### Update file attributes++```bash+curl -X POST "http://localhost:4000/v1/vector_stores/{vector_store_id}/files/{file_id}" \+ -H "Authorization: Bearer sk-1234" \+ -H "Content-Type: application/json" \+ -d '{+ "attributes": {+ "category": "support-faq",+ "language": "en"+ }+ }'+```diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.jsindex 99472981f0c..92592d3a473 100644--- a/docs/my-website/sidebars.js+++ b/docs/my-website/sidebars.js@@ -368,6 +368,7 @@ const sidebars = {]},"videos",+ "vector_store_files",{type: "category",label: "/mcp - Model Context Protocol",diff --git a/litellm/__init__.py b/litellm/__init__.pyindex 4993570aded..170566a0164 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -1386,6 +1386,20 @@ from .search.main import *from .realtime_api.main import _arealtimefrom .fine_tuning.main import *from .files.main import *+from .vector_store_files.main import (+ acreate as avector_store_file_create,+ adelete as avector_store_file_delete,+ alist as avector_store_file_list,+ aretrieve as avector_store_file_retrieve,+ aretrieve_content as avector_store_file_content,+ aupdate as avector_store_file_update,+ create as vector_store_file_create,+ delete as vector_store_file_delete,+ list as vector_store_file_list,+ retrieve as vector_store_file_retrieve,+ retrieve_content as vector_store_file_content,+ update as vector_store_file_update,+)from .scheduler import *from .cost_calculator import response_cost_calculator, cost_per_tokendiff --git a/litellm/llms/base_llm/vector_store_files/transformation.py b/litellm/llms/base_llm/vector_store_files/transformation.pynew file mode 100644index 00000000000..f751022faaf--- /dev/null+++ b/litellm/llms/base_llm/vector_store_files/transformation.py@@ -0,0 +1,226 @@+from abc import ABC, abstractmethod+from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union++import httpx++from litellm.types.router import GenericLiteLLMParams+from litellm.types.vector_store_files import (+ VectorStoreFileAuthCredentials,+ VectorStoreFileChunkingStrategy,+ VectorStoreFileContentResponse,+ VectorStoreFileCreateRequest,+ VectorStoreFileDeleteResponse,+ VectorStoreFileListQueryParams,+ VectorStoreFileListResponse,+ VectorStoreFileObject,+ VectorStoreFileUpdateRequest,+)++if TYPE_CHECKING:+ from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj++ from ..chat.transformation import BaseLLMException as _BaseLLMException++ LiteLLMLoggingObj = _LiteLLMLoggingObj+ BaseLLMException = _BaseLLMException+else:+ LiteLLMLoggingObj = Any+ BaseLLMException = Any+++class BaseVectorStoreFilesConfig(ABC):+ """Base configuration contract for provider-specific vector store file implementations."""++ def get_supported_openai_params(+ self,+ operation: str,+ ) -> Tuple[str, ...]:+ """Return the set of OpenAI params supported for the given operation."""++ return tuple()++ def map_openai_params(+ self,+ *,+ operation: str,+ non_default_params: Dict[str, Any],+ optional_params: Dict[str, Any],+ drop_params: bool,+ ) -> Dict[str, Any]:+ """Map non-default OpenAI params to provider-specific params."""++ return optional_params++ @abstractmethod+ def get_auth_credentials(+ self, litellm_params: Dict[str, Any]+ ) -> VectorStoreFileAuthCredentials:+ ...++ @abstractmethod+ def get_vector_store_file_endpoints_by_type(self) -> Dict[+ str, Tuple[Tuple[str, str], ...]+ ]:+ ...++ @abstractmethod+ def validate_environment(+ self,+ *,+ headers: Dict[str, str],+ litellm_params: Optional[GenericLiteLLMParams],+ ) -> Dict[str, str]:+ return {}++ @abstractmethod+ def get_complete_url(+ self,+ *,+ api_base: Optional[str],+ vector_store_id: str,+ litellm_params: Dict[str, Any],+ ) -> str:+ if api_base is None:+ raise ValueError("api_base is required")+ return api_base++ @abstractmethod+ def transform_create_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ create_request: VectorStoreFileCreateRequest,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_create_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ ...++ @abstractmethod+ def transform_list_vector_store_files_request(+ self,+ *,+ vector_store_id: str,+ query_params: VectorStoreFileListQueryParams,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_list_vector_store_files_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileListResponse:+ ...++ @abstractmethod+ def transform_retrieve_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_retrieve_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ ...++ @abstractmethod+ def transform_retrieve_vector_store_file_content_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_retrieve_vector_store_file_content_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileContentResponse:+ ...++ @abstractmethod+ def transform_update_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ update_request: VectorStoreFileUpdateRequest,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_update_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ ...++ @abstractmethod+ def transform_delete_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ ...++ @abstractmethod+ def transform_delete_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileDeleteResponse:+ ...++ def get_error_class(+ self,+ *,+ error_message: str,+ status_code: int,+ headers: Union[Dict[str, Any], httpx.Headers],+ ) -> BaseLLMException:+ from ..chat.transformation import BaseLLMException++ raise BaseLLMException(+ status_code=status_code,+ message=error_message,+ headers=headers,+ )++ def sign_request(+ self,+ *,+ headers: Dict[str, str],+ optional_params: Dict[str, Any],+ request_data: Dict[str, Any],+ api_base: str,+ api_key: Optional[str] = None,+ ) -> Tuple[Dict[str, str], Optional[bytes]]:+ return headers, None++ def prepare_chunking_strategy(+ self,+ chunking_strategy: Optional[VectorStoreFileChunkingStrategy],+ ) -> Optional[VectorStoreFileChunkingStrategy]:+ return chunking_strategydiff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.pyindex 05c640aa580..861da9d9a27 100644--- a/litellm/llms/custom_httpx/llm_http_handler.py+++ b/litellm/llms/custom_httpx/llm_http_handler.py@@ -48,6 +48,9 @@ from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfifrom litellm.llms.base_llm.search.transformation import BaseSearchConfig, SearchResponsefrom litellm.llms.base_llm.text_to_speech.transformation import BaseTextToSpeechConfigfrom litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfig+from litellm.llms.base_llm.vector_store_files.transformation import (+ BaseVectorStoreFilesConfig,+)from litellm.llms.base_llm.videos.transformation import BaseVideoConfigfrom litellm.llms.custom_httpx.http_handler import (AsyncHTTPHandler,@@ -92,6 +95,15 @@ from litellm.types.vector_stores import (VectorStoreSearchOptionalRequestParams,VectorStoreSearchResponse,)+from litellm.types.vector_store_files import (+ VectorStoreFileContentResponse,+ VectorStoreFileCreateRequest,+ VectorStoreFileDeleteResponse,+ VectorStoreFileListQueryParams,+ VectorStoreFileListResponse,+ VectorStoreFileObject,+ VectorStoreFileUpdateRequest,+)from litellm.types.videos.main import VideoObjectfrom litellm.utils import (CustomStreamWrapper,@@ -3529,6 +3541,7 @@ class BaseLLMHTTPHandler:BaseImageEditConfig,BaseImageGenerationConfig,BaseVectorStoreConfig,+ BaseVectorStoreFilesConfig,BaseGoogleGenAIGenerateContentConfig,BaseAnthropicMessagesConfig,BaseBatchesConfig,@@ -6000,6 +6013,909 @@ class BaseLLMHTTPHandler:response=response,)+ #####################################################################+ ################ Vector Store Files HANDLERS ########################+ #####################################################################+ async def async_vector_store_file_create_handler(+ self,+ *,+ vector_store_id: str,+ create_request: VectorStoreFileCreateRequest,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileObject:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )++ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ request_dict = dict(create_request)+ if extra_body:+ request_dict.update(extra_body)++ (+ url,+ request_body,+ ) = vector_store_files_provider_config.transform_create_vector_store_file_request(+ vector_store_id=vector_store_id,+ create_request=cast(VectorStoreFileCreateRequest, request_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_body,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.post(+ url=url, headers=headers, json=request_body, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_create_vector_store_file_response(+ response=response+ )++ def vector_store_file_create_handler(+ self,+ *,+ vector_store_id: str,+ create_request: VectorStoreFileCreateRequest,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ if _is_async:+ return self.async_vector_store_file_create_handler(+ vector_store_id=vector_store_id,+ create_request=create_request,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )++ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ request_dict = dict(create_request)+ if extra_body:+ request_dict.update(extra_body)++ (+ url,+ request_body,+ ) = vector_store_files_provider_config.transform_create_vector_store_file_request(+ vector_store_id=vector_store_id,+ create_request=cast(VectorStoreFileCreateRequest, request_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_body,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.post(+ url=url, headers=headers, json=request_body, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_create_vector_store_file_response(+ response=response+ )++ async def async_vector_store_file_list_handler(+ self,+ *,+ vector_store_id: str,+ query_params: VectorStoreFileListQueryParams,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileListResponse:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ params_dict = dict(query_params)+ if extra_query:+ params_dict.update(extra_query)++ (+ url,+ request_params,+ ) = vector_store_files_provider_config.transform_list_vector_store_files_request(+ vector_store_id=vector_store_id,+ query_params=cast(VectorStoreFileListQueryParams, params_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_list_vector_store_files_response(+ response=response+ )++ def vector_store_file_list_handler(+ self,+ *,+ vector_store_id: str,+ query_params: VectorStoreFileListQueryParams,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[+ VectorStoreFileListResponse, Coroutine[Any, Any, VectorStoreFileListResponse]+ ]:+ if _is_async:+ return self.async_vector_store_file_list_handler(+ vector_store_id=vector_store_id,+ query_params=query_params,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ extra_query=extra_query,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ params_dict = dict(query_params)+ if extra_query:+ params_dict.update(extra_query)++ (+ url,+ request_params,+ ) = vector_store_files_provider_config.transform_list_vector_store_files_request(+ vector_store_id=vector_store_id,+ query_params=cast(VectorStoreFileListQueryParams, params_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_list_vector_store_files_response(+ response=response+ )++ async def async_vector_store_file_retrieve_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileObject:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_retrieve_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_retrieve_vector_store_file_response(+ response=response+ )++ def vector_store_file_retrieve_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ if _is_async:+ return self.async_vector_store_file_retrieve_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_retrieve_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_retrieve_vector_store_file_response(+ response=response+ )++ async def async_vector_store_file_content_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileContentResponse:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_retrieve_vector_store_file_content_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_retrieve_vector_store_file_content_response(+ response=response+ )++ def vector_store_file_content_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[+ VectorStoreFileContentResponse,+ Coroutine[Any, Any, VectorStoreFileContentResponse],+ ]:+ if _is_async:+ return self.async_vector_store_file_content_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_retrieve_vector_store_file_content_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.get(+ url=url, headers=headers, params=request_params+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_retrieve_vector_store_file_content_response(+ response=response+ )++ async def async_vector_store_file_update_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ update_request: VectorStoreFileUpdateRequest,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileObject:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ request_dict = dict(update_request)+ if extra_body:+ request_dict.update(extra_body)++ (+ url,+ request_body,+ ) = vector_store_files_provider_config.transform_update_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ update_request=cast(VectorStoreFileUpdateRequest, request_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_body,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.post(+ url=url, headers=headers, json=request_body, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_update_vector_store_file_response(+ response=response+ )++ def vector_store_file_update_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ update_request: VectorStoreFileUpdateRequest,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ if _is_async:+ return self.async_vector_store_file_update_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ update_request=update_request,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ request_dict = dict(update_request)+ if extra_body:+ request_dict.update(extra_body)++ (+ url,+ request_body,+ ) = vector_store_files_provider_config.transform_update_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ update_request=cast(VectorStoreFileUpdateRequest, request_dict),+ api_base=api_base,+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_body,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.post(+ url=url, headers=headers, json=request_body, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_update_vector_store_file_response(+ response=response+ )++ async def async_vector_store_file_delete_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ ) -> VectorStoreFileDeleteResponse:+ if client is None or not isinstance(client, AsyncHTTPHandler):+ async_httpx_client = get_async_httpx_client(+ llm_provider=litellm.LlmProviders(custom_llm_provider),+ params={"ssl_verify": litellm_params.get("ssl_verify", None)},+ )+ else:+ async_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_delete_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = await async_httpx_client.delete(+ url=url, headers=headers, params=request_params, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_delete_vector_store_file_response(+ response=response+ )++ def vector_store_file_delete_handler(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ vector_store_files_provider_config: BaseVectorStoreFilesConfig,+ custom_llm_provider: str,+ litellm_params: GenericLiteLLMParams,+ logging_obj: LiteLLMLoggingObj,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,+ _is_async: bool = False,+ ) -> Union[+ VectorStoreFileDeleteResponse,+ Coroutine[Any, Any, VectorStoreFileDeleteResponse],+ ]:+ if _is_async:+ return self.async_vector_store_file_delete_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=vector_store_files_provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=logging_obj,+ extra_headers=extra_headers,+ timeout=timeout,+ client=client if isinstance(client, AsyncHTTPHandler) else None,+ )++ if client is None or not isinstance(client, HTTPHandler):+ sync_httpx_client = _get_httpx_client(+ params={"ssl_verify": litellm_params.get("ssl_verify", None)}+ )+ else:+ sync_httpx_client = client++ headers = vector_store_files_provider_config.validate_environment(+ headers=extra_headers or {}, litellm_params=litellm_params+ )+ if extra_headers:+ headers.update(extra_headers)++ api_base = vector_store_files_provider_config.get_complete_url(+ api_base=litellm_params.api_base,+ vector_store_id=vector_store_id,+ litellm_params=dict(litellm_params),+ )++ url, request_params = (+ vector_store_files_provider_config.transform_delete_vector_store_file_request(+ vector_store_id=vector_store_id,+ file_id=file_id,+ api_base=api_base,+ )+ )++ logging_obj.pre_call(+ input="",+ api_key="",+ additional_args={+ "complete_input_dict": request_params,+ "api_base": api_base,+ "headers": headers,+ },+ )++ try:+ response = sync_httpx_client.delete(+ url=url, headers=headers, params=request_params, timeout=timeout+ )+ except Exception as e:+ raise self._handle_error(+ e=e, provider_config=vector_store_files_provider_config+ )++ return vector_store_files_provider_config.transform_delete_vector_store_file_response(+ response=response+ )+##################################################################################### Google GenAI GENERATE CONTENT HANDLER ################################################################################################diff --git a/litellm/llms/fal_ai/__init__.py b/litellm/llms/fal_ai/__init__.pyindex 1f4cbe0e9ce..34cac014ce9 100644--- a/litellm/llms/fal_ai/__init__.py+++ b/litellm/llms/fal_ai/__init__.py@@ -2,6 +2,7 @@ from .cost_calculator import cost_calculatorfrom .image_generation import (FalAIBaseConfig,FalAIBriaConfig,+ FalAIFluxProV11Config,FalAIFluxProV11UltraConfig,FalAIFluxSchnellConfig,FalAIImageGenerationConfig,@@ -18,6 +19,7 @@ __all__ = ["FalAIImagen4Config","FalAIRecraftV3Config","FalAIBriaConfig",+ "FalAIFluxProV11Config","FalAIFluxProV11UltraConfig","FalAIFluxSchnellConfig","FalAIStableDiffusionConfig",diff --git a/litellm/llms/fal_ai/image_generation/__init__.py b/litellm/llms/fal_ai/image_generation/__init__.pyindex b4ae6734c64..27817ae5a5f 100644--- a/litellm/llms/fal_ai/image_generation/__init__.py+++ b/litellm/llms/fal_ai/image_generation/__init__.py@@ -3,12 +3,18 @@ from litellm.llms.base_llm.image_generation.transformation import ()from .bria_transformation import FalAIBriaConfig+from .flux_pro_v11_transformation import FalAIFluxProV11Configfrom .flux_pro_v11_ultra_transformation import FalAIFluxProV11UltraConfigfrom .flux_schnell_transformation import FalAIFluxSchnellConfigfrom .imagen4_transformation import FalAIImagen4Configfrom .recraft_v3_transformation import FalAIRecraftV3Config+from .ideogram_v3_transformation import FalAIIdeogramV3Configfrom .stable_diffusion_transformation import FalAIStableDiffusionConfigfrom .transformation import FalAIBaseConfig, FalAIImageGenerationConfig+from .bytedance_transformation import (+ FalAIBytedanceSeedreamV3Config,+ FalAIBytedanceDreaminaV31Config,+)__all__ = ["FalAIBaseConfig",@@ -16,9 +22,13 @@ __all__ = ["FalAIImagen4Config","FalAIRecraftV3Config","FalAIBriaConfig",+ "FalAIFluxProV11Config","FalAIFluxProV11UltraConfig","FalAIFluxSchnellConfig","FalAIStableDiffusionConfig",+ "FalAIBytedanceSeedreamV3Config",+ "FalAIBytedanceDreaminaV31Config",+ "FalAIIdeogramV3Config",]@@ -41,10 +51,18 @@ def get_fal_ai_image_generation_config(model: str) -> BaseImageGenerationConfig:return FalAIRecraftV3Config()elif "bria" in model_lower:return FalAIBriaConfig()- elif "flux-pro" in model_lower and "ultra" in model_lower:- return FalAIFluxProV11UltraConfig()+ elif "flux-pro" in model_lower:+ if "ultra" in model_lower:+ return FalAIFluxProV11UltraConfig()+ return FalAIFluxProV11Config()elif "flux/schnell" in model_lower or "flux-schnell" in model_lower or "schnell" in model_lower:return FalAIFluxSchnellConfig()+ elif "bytedance/seedream" in model_lower:+ return FalAIBytedanceSeedreamV3Config()+ elif "bytedance/dreamina" in model_lower:+ return FalAIBytedanceDreaminaV31Config()+ elif "ideogram" in model_lower:+ return FalAIIdeogramV3Config()elif "stable-diffusion" in model_lower:return FalAIStableDiffusionConfig()diff --git a/litellm/llms/fal_ai/image_generation/bytedance_transformation.py b/litellm/llms/fal_ai/image_generation/bytedance_transformation.pynew file mode 100644index 00000000000..d6aa242edc4--- /dev/null+++ b/litellm/llms/fal_ai/image_generation/bytedance_transformation.py@@ -0,0 +1,106 @@+from typing import Any++from .flux_pro_v11_ultra_transformation import FalAIFluxProV11UltraConfig+++class FalAIBytedanceBaseConfig(FalAIFluxProV11UltraConfig):+ """+ Shared configuration for Fal AI ByteDance text-to-image models that follow+ the Flux Schnell style parameter mapping.++ These models accept the OpenAI-compatible `size` parameter in LiteLLM+ requests but expect `image_size` enums or custom size objects on Fal AI.+ """++ _OPENAI_SIZE_TO_IMAGE_SIZE = {+ "1024x1024": "square_hd",+ "512x512": "square",+ "1792x1024": "landscape_16_9",+ "1024x1792": "portrait_16_9",+ "1024x768": "landscape_4_3",+ "768x1024": "portrait_4_3",+ }++ def map_openai_params(+ self,+ non_default_params: dict,+ optional_params: dict,+ model: str,+ drop_params: bool,+ ) -> dict:+ supported_params = self.get_supported_openai_params(model)++ param_mapping = {+ "n": "num_images",+ "response_format": "output_format",+ "size": "image_size",+ }++ for k in non_default_params.keys():+ if k not in optional_params.keys():+ if k in supported_params:+ mapped_key = param_mapping.get(k, k)+ mapped_value = non_default_params[k]++ if k == "response_format":+ if mapped_value in ["b64_json", "url"]:+ mapped_value = "jpeg"+ elif k == "size":+ mapped_value = self._map_image_size(mapped_value)++ optional_params[mapped_key] = mapped_value+ elif drop_params:+ continue+ else:+ raise ValueError(+ f"Parameter {k} is not supported for model {model}. "+ f"Supported parameters are {supported_params}. "+ "Set drop_params=True to drop unsupported parameters."+ )++ return optional_params++ def _map_image_size(self, size: Any) -> Any:+ if isinstance(size, dict):+ return size++ if not isinstance(size, str):+ return size++ if size in self._OPENAI_SIZE_TO_IMAGE_SIZE:+ return self._OPENAI_SIZE_TO_IMAGE_SIZE[size]++ if "x" in size:+ try:+ width_str, height_str = size.split("x")+ width = int(width_str)+ height = int(height_str)+ return {"width": width, "height": height}+ except (ValueError, AttributeError, ZeroDivisionError):+ pass++ return "landscape_4_3"+++class FalAIBytedanceSeedreamV3Config(FalAIBytedanceBaseConfig):+ """+ Configuration for Fal AI ByteDance Seedream v3 text-to-image model.++ Model endpoint: fal-ai/bytedance/seedream/v3/text-to-image+ Documentation: https://fal.ai/models/fal-ai/bytedance/seedream/v3/text-to-image+ """++ IMAGE_GENERATION_ENDPOINT: str = "fal-ai/bytedance/seedream/v3/text-to-image"+++class FalAIBytedanceDreaminaV31Config(FalAIBytedanceBaseConfig):+ """+ Configuration for Fal AI ByteDance Dreamina v3.1 text-to-image model.++ Model endpoint: fal-ai/bytedance/dreamina/v3.1/text-to-image+ Documentation: https://fal.ai/models/fal-ai/bytedance/dreamina/v3.1/text-to-image+ """++ IMAGE_GENERATION_ENDPOINT: str = "fal-ai/bytedance/dreamina/v3.1/text-to-image"++diff --git a/litellm/llms/fal_ai/image_generation/flux_pro_v11_transformation.py b/litellm/llms/fal_ai/image_generation/flux_pro_v11_transformation.pynew file mode 100644index 00000000000..0bd6a5eab64--- /dev/null+++ b/litellm/llms/fal_ai/image_generation/flux_pro_v11_transformation.py@@ -0,0 +1,91 @@+from typing import Any, Optional++from .flux_pro_v11_ultra_transformation import FalAIFluxProV11UltraConfig+++class FalAIFluxProV11Config(FalAIFluxProV11UltraConfig):+ """+ Configuration for Fal AI Flux Pro v1.1 model.++ FLUX Pro v1.1 leverages the same overall request/response structure as the+ Ultra variant but expects the `image_size` parameter instead of+ `aspect_ratio`.++ Model endpoint: fal-ai/flux-pro/v1.1+ Documentation: https://fal.ai/models/fal-ai/flux-pro/v1.1+ """++ IMAGE_GENERATION_ENDPOINT: str = "fal-ai/flux-pro/v1.1"++ _OPENAI_SIZE_TO_IMAGE_SIZE = {+ "1024x1024": "square_hd",+ "512x512": "square",+ "1792x1024": "landscape_16_9",+ "1024x1792": "portrait_16_9",+ "1024x768": "landscape_4_3",+ "768x1024": "portrait_4_3",+ }++ def map_openai_params(+ self,+ non_default_params: dict,+ optional_params: dict,+ model: str,+ drop_params: bool,+ ) -> dict:+ """+ Override size handling to map to Flux Pro v1.1 image_size enums/object.+ """+ supported_params = self.get_supported_openai_params(model)++ param_mapping = {+ "n": "num_images",+ "response_format": "output_format",+ "size": "image_size",+ }++ for k in non_default_params.keys():+ if k not in optional_params.keys():+ if k in supported_params:+ mapped_key = param_mapping.get(k, k)+ mapped_value = non_default_params[k]++ if k == "response_format":+ if mapped_value in ["b64_json", "url"]:+ mapped_value = "jpeg"+ elif k == "size":+ mapped_value = self._map_image_size(mapped_value)++ optional_params[mapped_key] = mapped_value+ elif drop_params:+ continue+ else:+ raise ValueError(+ f"Parameter {k} is not supported for model {model}. "+ f"Supported parameters are {supported_params}. "+ "Set drop_params=True to drop unsupported parameters."+ )++ return optional_params++ def _map_image_size(self, size: Any) -> Any:+ if isinstance(size, dict):+ return size+ if not isinstance(size, str):+ return size++ if size in self._OPENAI_SIZE_TO_IMAGE_SIZE:+ return self._OPENAI_SIZE_TO_IMAGE_SIZE[size]++ if "x" in size:+ try:+ width_str, height_str = size.split("x")+ width = int(width_str)+ height = int(height_str)+ return {"width": width, "height": height}+ except (ValueError, AttributeError, ZeroDivisionError):+ pass++ return "landscape_4_3"++diff --git a/litellm/llms/fal_ai/image_generation/ideogram_v3_transformation.py b/litellm/llms/fal_ai/image_generation/ideogram_v3_transformation.pynew file mode 100644index 00000000000..f05ffa888ef--- /dev/null+++ b/litellm/llms/fal_ai/image_generation/ideogram_v3_transformation.py@@ -0,0 +1,193 @@+from typing import TYPE_CHECKING, Any, List, Optional++import httpx++from litellm.types.llms.openai import OpenAIImageGenerationOptionalParams+from litellm.types.utils import ImageObject, ImageResponse++from .transformation import FalAIBaseConfig++if TYPE_CHECKING:+ from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj++ LiteLLMLoggingObj = _LiteLLMLoggingObj+else:+ LiteLLMLoggingObj = Any+++class FalAIIdeogramV3Config(FalAIBaseConfig):+ """+ Configuration for fal-ai/ideogram/v3 image generation.++ The Ideogram v3 endpoint exposes multiple generation modes (text-to-image,+ remixing, reframing, background replacement, character workflows, etc.).+ LiteLLM focuses on the text-to-image interface to maintain OpenAI parity.++ Model endpoint: fal-ai/ideogram/v3+ Documentation: https://fal.ai/models/fal-ai/ideogram/v3+ """++ IMAGE_GENERATION_ENDPOINT: str = "fal-ai/ideogram/v3"++ _OPENAI_SIZE_TO_IMAGE_SIZE = {+ "1024x1024": "square_hd",+ "512x512": "square",+ "1024x768": "landscape_4_3",+ "768x1024": "portrait_4_3",+ "1536x1024": "landscape_16_9",+ "1024x1536": "portrait_16_9",+ }++ def get_supported_openai_params(+ self, model: str+ ) -> List[OpenAIImageGenerationOptionalParams]:+ """+ Ideogram v3 accepts the core OpenAI image parameters.+ """++ return [+ "n",+ "response_format",+ "size",+ ]++ def map_openai_params(+ self,+ non_default_params: dict,+ optional_params: dict,+ model: str,+ drop_params: bool,+ ) -> dict:+ """+ Map OpenAI-style parameters onto Ideogram's request schema.+ """++ supported_params = self.get_supported_openai_params(model)++ for k in non_default_params.keys():+ if k in optional_params:+ continue++ if k not in supported_params:+ if drop_params:+ continue+ raise ValueError(+ f"Parameter {k} is not supported for model {model}. "+ f"Supported parameters are {supported_params}. "+ "Set drop_params=True to drop unsupported parameters."+ )++ value = non_default_params[k]++ if k == "n":+ optional_params["num_images"] = value+ elif k == "size":+ optional_params["image_size"] = self._map_image_size(value)+ elif k == "response_format":+ # Ideogram always returns URLs; nothing to map but don't error.+ continue++ return optional_params++ def _map_image_size(self, size: Any) -> Any:+ if isinstance(size, dict):+ width = size.get("width")+ height = size.get("height")+ if isinstance(width, int) and isinstance(height, int):+ return {"width": width, "height": height}+ return size++ if not isinstance(size, str):+ return size++ normalized = size.strip()+ if normalized in self._OPENAI_SIZE_TO_IMAGE_SIZE:+ return self._OPENAI_SIZE_TO_IMAGE_SIZE[normalized]++ if "x" in normalized:+ try:+ width_str, height_str = normalized.split("x")+ width = int(width_str)+ height = int(height_str)+ return {"width": width, "height": height}+ except (ValueError, AttributeError):+ pass++ # Fallback to a safe default that Ideogram accepts.+ return "square_hd"++ def transform_image_generation_request(+ self,+ model: str,+ prompt: str,+ optional_params: dict,+ litellm_params: dict,+ headers: dict,+ ) -> dict:+ """+ Construct the request payload for Ideogram v3.++ Required:+ - prompt: text prompt describing the scene.++ Optional (subset):+ - rendering_speed, style_preset, style, style_codes, color_palette,+ image_urls, style_reference_images, expand_prompt, seed,+ negative_prompt, image_size, etc.+ """++ return {+ "prompt": prompt,+ **optional_params,+ }++ def transform_image_generation_response(+ self,+ model: str,+ raw_response: httpx.Response,+ model_response: ImageResponse,+ logging_obj: LiteLLMLoggingObj,+ request_data: dict,+ optional_params: dict,+ litellm_params: dict,+ encoding: Any,+ api_key: Optional[str] = None,+ json_mode: Optional[bool] = None,+ ) -> ImageResponse:+ """+ Parse Ideogram v3 responses which contain a list of File objects.+ """++ try:+ response_data = raw_response.json()+ except Exception as e:+ raise self.get_error_class(+ error_message=f"Error transforming image generation response: {e}",+ status_code=raw_response.status_code,+ headers=raw_response.headers,+ )++ if not model_response.data:+ model_response.data = []++ images = response_data.get("images", [])+ if isinstance(images, list):+ for image_entry in images:+ if isinstance(image_entry, dict):+ url = image_entry.get("url")+ else:+ url = image_entry++ model_response.data.append(+ ImageObject(+ url=url,+ b64_json=None,+ )+ )++ if hasattr(model_response, "_hidden_params") and "seed" in response_data:+ model_response._hidden_params["seed"] = response_data["seed"]++ return model_response++diff --git a/litellm/llms/openai/vector_store_files/transformation.py b/litellm/llms/openai/vector_store_files/transformation.pynew file mode 100644index 00000000000..8953e404f3e--- /dev/null+++ b/litellm/llms/openai/vector_store_files/transformation.py@@ -0,0 +1,258 @@+from typing import Any, Dict, Optional, Tuple, cast++import httpx++import litellm+from litellm.llms.base_llm.vector_store_files.transformation import (+ BaseVectorStoreFilesConfig,+)+from litellm.secret_managers.main import get_secret_str+from litellm.types.router import GenericLiteLLMParams+from litellm.types.vector_store_files import (+ VectorStoreFileAuthCredentials,+ VectorStoreFileContentResponse,+ VectorStoreFileCreateRequest,+ VectorStoreFileDeleteResponse,+ VectorStoreFileListQueryParams,+ VectorStoreFileListResponse,+ VectorStoreFileObject,+ VectorStoreFileUpdateRequest,+)+from litellm.utils import add_openai_metadata+++def _clean_dict(source: Dict[str, Any]) -> Dict[str, Any]:+ return {k: v for k, v in source.items() if v is not None}+++class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig):+ ASSISTANTS_HEADER_KEY = "OpenAI-Beta"+ ASSISTANTS_HEADER_VALUE = "assistants=v2"++ def get_auth_credentials(+ self, litellm_params: Dict[str, Any]+ ) -> VectorStoreFileAuthCredentials:+ api_key = litellm_params.get("api_key")+ if api_key is None:+ raise ValueError("api_key is required")+ return {+ "headers": {+ "Authorization": f"Bearer {api_key}",+ }+ }++ def get_vector_store_file_endpoints_by_type(self) -> Dict[+ str, Tuple[Tuple[str, str], ...]+ ]:+ return {+ "read": (+ ("GET", "/vector_stores/{vector_store_id}/files"),+ ("GET", "/vector_stores/{vector_store_id}/files/{file_id}"),+ (+ "GET",+ "/vector_stores/{vector_store_id}/files/{file_id}/content",+ ),+ ),+ "write": (+ ("POST", "/vector_stores/{vector_store_id}/files"),+ ("POST", "/vector_stores/{vector_store_id}/files/{file_id}"),+ ("DELETE", "/vector_stores/{vector_store_id}/files/{file_id}"),+ ),+ }++ def validate_environment(+ self,+ *,+ headers: Dict[str, str],+ litellm_params: Optional[GenericLiteLLMParams],+ ) -> Dict[str, str]:+ litellm_params = litellm_params or GenericLiteLLMParams()+ api_key = (+ litellm_params.api_key+ or litellm.api_key+ or litellm.openai_key+ or get_secret_str("OPENAI_API_KEY")+ )+ headers.update(+ {+ "Authorization": f"Bearer {api_key}",+ "Content-Type": "application/json",+ }+ )+ if self.ASSISTANTS_HEADER_KEY not in headers:+ headers[self.ASSISTANTS_HEADER_KEY] = self.ASSISTANTS_HEADER_VALUE+ return headers++ def get_complete_url(+ self,+ *,+ api_base: Optional[str],+ vector_store_id: str,+ litellm_params: Dict[str, Any],+ ) -> str:+ base_url = (+ api_base+ or litellm.api_base+ or get_secret_str("OPENAI_BASE_URL")+ or get_secret_str("OPENAI_API_BASE")+ or "https://api.openai.com/v1"+ )+ base_url = base_url.rstrip("/")+ return f"{base_url}/vector_stores/{vector_store_id}/files"++ def transform_create_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ create_request: VectorStoreFileCreateRequest,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ payload: Dict[str, Any] = _clean_dict(dict(create_request))+ attributes = payload.get("attributes")+ if isinstance(attributes, dict):+ filtered_attributes = add_openai_metadata(attributes)+ if filtered_attributes is not None:+ payload["attributes"] = filtered_attributes+ else:+ payload.pop("attributes", None)+ url = api_base+ return url, payload++ def transform_create_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ try:+ return cast(VectorStoreFileObject, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )++ def transform_list_vector_store_files_request(+ self,+ *,+ vector_store_id: str,+ query_params: VectorStoreFileListQueryParams,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ params = _clean_dict(dict(query_params))+ return api_base, params++ def transform_list_vector_store_files_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileListResponse:+ try:+ return cast(VectorStoreFileListResponse, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )++ def transform_retrieve_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ return f"{api_base}/{file_id}", {}++ def transform_retrieve_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ try:+ return cast(VectorStoreFileObject, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )++ def transform_retrieve_vector_store_file_content_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ return f"{api_base}/{file_id}/content", {}++ def transform_retrieve_vector_store_file_content_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileContentResponse:+ try:+ return cast(VectorStoreFileContentResponse, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )++ def transform_update_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ update_request: VectorStoreFileUpdateRequest,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ payload: Dict[str, Any] = dict(update_request)+ attributes = payload.get("attributes")+ if isinstance(attributes, dict):+ filtered_attributes = add_openai_metadata(attributes)+ if filtered_attributes is not None:+ payload["attributes"] = filtered_attributes+ else:+ payload.pop("attributes", None)+ return f"{api_base}/{file_id}", payload++ def transform_update_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileObject:+ try:+ return cast(VectorStoreFileObject, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )++ def transform_delete_vector_store_file_request(+ self,+ *,+ vector_store_id: str,+ file_id: str,+ api_base: str,+ ) -> Tuple[str, Dict[str, Any]]:+ return f"{api_base}/{file_id}", {}++ def transform_delete_vector_store_file_response(+ self,+ *,+ response: httpx.Response,+ ) -> VectorStoreFileDeleteResponse:+ try:+ return cast(VectorStoreFileDeleteResponse, response.json())+ except Exception as exc: # noqa: BLE001+ raise self.get_error_class(+ error_message=str(exc),+ status_code=response.status_code,+ headers=response.headers,+ )diff --git a/litellm/llms/openai/vector_stores/transformation.py b/litellm/llms/openai/vector_stores/transformation.pyindex 5689e249bc0..c763ed1c8da 100644--- a/litellm/llms/openai/vector_stores/transformation.py+++ b/litellm/llms/openai/vector_stores/transformation.py@@ -145,6 +145,8 @@ class OpenAIVectorStoreConfig(BaseVectorStoreConfig):) -> Tuple[str, Dict]:url = api_base # Base URL for creating vector storesmetadata = vector_store_create_optional_params.get("metadata", None)+ metadata_payload = add_openai_metadata(metadata)+typed_request_body = VectorStoreCreateRequest(name=vector_store_create_optional_params.get("name", None),file_ids=vector_store_create_optional_params.get("file_ids", None),@@ -154,7 +156,7 @@ class OpenAIVectorStoreConfig(BaseVectorStoreConfig):chunking_strategy=vector_store_create_optional_params.get("chunking_strategy", None),- metadata=add_openai_metadata(metadata) if metadata is not None else None,+ metadata=metadata_payload,)dict_request_body = cast(dict, typed_request_body)diff --git a/litellm/main.py b/litellm/main.pyindex 7d420bd36bf..14d0b04b7b5 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -2086,10 +2086,10 @@ def completion( # type: ignore # noqa: PLR0915if extra_headers is not None:optional_params["extra_headers"] = extra_headers- if (- litellm.enable_preview_features and metadata is not None- ): # [PREVIEW] allow metadata to be passed to OPENAI- optional_params["metadata"] = add_openai_metadata(metadata)+ if litellm.enable_preview_features:+ metadata_payload = add_openai_metadata(metadata)+ if metadata_payload is not None:+ optional_params["metadata"] = metadata_payload## LOAD CONFIG - if setconfig = litellm.OpenAIConfig.get_config()diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 0fe71e4541e..367f788dd34 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -8515,10 +8515,18 @@"/v1/images/generations"]},+ "fal_ai/fal-ai/flux-pro/v1.1": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.04,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },"fal_ai/fal-ai/flux-pro/v1.1-ultra": {"litellm_provider": "fal_ai","mode": "image_generation",- "output_cost_per_image": 0.0398,+ "output_cost_per_image": 0.06,"supported_endpoints": ["/v1/images/generations"]@@ -8531,6 +8539,30 @@"/v1/images/generations"]},+ "fal_ai/fal-ai/bytedance/seedream/v3/text-to-image": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.03,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },+ "fal_ai/fal-ai/bytedance/dreamina/v3.1/text-to-image": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.03,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },+ "fal_ai/fal-ai/ideogram/v3": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.06,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },"fal_ai/fal-ai/imagen4/preview": {"litellm_provider": "fal_ai","mode": "image_generation",diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex 8b2a188c708..90fe179fcd8 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -339,6 +339,12 @@ class LiteLLMRoutes(enum.Enum):"/v1/vector_stores","/vector_stores/{vector_store_id}/search","/v1/vector_stores/{vector_store_id}/search",+ "/vector_stores/{vector_store_id}/files",+ "/v1/vector_stores/{vector_store_id}/files",+ "/vector_stores/{vector_store_id}/files/{file_id}",+ "/v1/vector_stores/{vector_store_id}/files/{file_id}",+ "/vector_stores/{vector_store_id}/files/{file_id}/content",+ "/v1/vector_stores/{vector_store_id}/files/{file_id}/content",# search"/search","/v1/search",diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.pyindex 1029b1964ab..835afbdc238 100644--- a/litellm/proxy/common_request_processing.py+++ b/litellm/proxy/common_request_processing.py@@ -315,6 +315,12 @@ class ProxyBaseLLMRequestProcessing:"allm_passthrough_route","avector_store_search","avector_store_create",+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete","aocr","asearch","avideo_generation",@@ -418,6 +424,12 @@ class ProxyBaseLLMRequestProcessing:"allm_passthrough_route","avector_store_search","avector_store_create",+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete","aocr","asearch","avideo_generation",diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 10f75185564..a6e73199f0e 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -379,6 +379,9 @@ from litellm.proxy.utils import (update_spend,)from litellm.proxy.vector_store_endpoints.endpoints import router as vector_store_router+from litellm.proxy.vector_store_files_endpoints.endpoints import (+ router as vector_store_files_router,+)from litellm.proxy.vertex_ai_endpoints.langfuse_endpoints import (router as langfuse_router,)@@ -10084,6 +10087,7 @@ app.include_router(search_router)app.include_router(image_router)app.include_router(fine_tuning_router)app.include_router(vector_store_router)+app.include_router(vector_store_files_router)app.include_router(credential_router)app.include_router(llm_passthrough_router)app.include_router(mcp_management_router)diff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.pyindex 1ac5aa625a4..7bb242ae30d 100644--- a/litellm/proxy/route_llm_request.py+++ b/litellm/proxy/route_llm_request.py@@ -109,6 +109,12 @@ async def route_request("allm_passthrough_route","avector_store_search","avector_store_create",+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete","aocr","asearch","avideo_generation",@@ -168,6 +174,10 @@ async def route_request("avideo_status","avideo_content","avideo_remix",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_delete",] and (data.get("model") is None or data.get("model") == ""):# These video endpoints don't need a model, use custom_llm_providerreturn getattr(litellm, f"{route_type}")(**data)@@ -214,6 +224,12 @@ async def route_request("alist_input_items","avector_store_create","avector_store_search",+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete","asearch","acreate_container","alist_containers",diff --git a/litellm/proxy/vector_store_endpoints/utils.py b/litellm/proxy/vector_store_endpoints/utils.pyindex 81c205095c1..5499abb19d5 100644--- a/litellm/proxy/vector_store_endpoints/utils.py+++ b/litellm/proxy/vector_store_endpoints/utils.py@@ -7,6 +7,16 @@ from litellm.types.utils import LlmProvidersfrom litellm.utils import ProviderConfigManager+def _does_endpoint_match(endpoint_path: str, request_path: str) -> bool:+ if endpoint_path in request_path:+ return True+ if "{" in endpoint_path:+ prefix = endpoint_path.split("{", 1)[0]+ if prefix and prefix in request_path:+ return True+ return False++def check_vector_store_permission(index_name: str,permission: str,@@ -95,13 +105,17 @@ def is_allowed_to_call_vector_store_endpoint(# Determine the permission type based on the requestpermission_type = Nonefor endpoint in provider_vector_store_endpoints["read"]:- if request.method == endpoint[0] and endpoint[1] in request.url.path:+ if request.method == endpoint[0] and _does_endpoint_match(+ endpoint[1], request.url.path+ ):permission_type = "read"breakif permission_type is None:for endpoint in provider_vector_store_endpoints["write"]:- if request.method == endpoint[0] and endpoint[1] in request.url.path:+ if request.method == endpoint[0] and _does_endpoint_match(+ endpoint[1], request.url.path+ ):permission_type = "write"break@@ -123,3 +137,63 @@ def is_allowed_to_call_vector_store_endpoint()return has_permission+++def is_allowed_to_call_vector_store_files_endpoint(+ provider: LlmProviders,+ vector_store_id: str,+ request: Request,+ user_api_key_dict: UserAPIKeyAuth,+) -> Optional[Literal[True]]:+ if (+ user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN+ or user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value+ ):+ return True++ key_metadata = user_api_key_dict.metadata+ team_metadata = user_api_key_dict.team_metadata++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=provider+ )+ if provider_config is None:+ return None++ provider_vector_store_endpoints = (+ provider_config.get_vector_store_file_endpoints_by_type()+ )++ permission_type: Optional[str] = None+ for endpoint in provider_vector_store_endpoints.get("read", ()):+ if request.method == endpoint[0] and _does_endpoint_match(+ endpoint[1], request.url.path+ ):+ permission_type = "read"+ break++ if permission_type is None:+ for endpoint in provider_vector_store_endpoints.get("write", ()):+ if request.method == endpoint[0] and _does_endpoint_match(+ endpoint[1], request.url.path+ ):+ permission_type = "write"+ break++ if permission_type is None:+ return None++ has_permission = check_vector_store_permission(+ index_name=vector_store_id,+ permission=permission_type,+ key_metadata=key_metadata,+ team_metadata=team_metadata,+ )++ if not has_permission:+ raise HTTPException(+ status_code=403,+ detail=f"User does not have permission to call vector store file endpoint {vector_store_id}. Ask your administrator to add the necessary permissions to your API key/Team.",+ )++ return has_permissiondiff --git a/litellm/proxy/vector_store_files_endpoints/__init__.py b/litellm/proxy/vector_store_files_endpoints/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/litellm/proxy/vector_store_files_endpoints/endpoints.py b/litellm/proxy/vector_store_files_endpoints/endpoints.pynew file mode 100644index 00000000000..6ac5cd57724--- /dev/null+++ b/litellm/proxy/vector_store_files_endpoints/endpoints.py@@ -0,0 +1,580 @@+from typing import Dict, Optional++import litellm+from fastapi import APIRouter, Depends, Request, Response+from fastapi.responses import ORJSONResponse++from litellm.proxy._types import UserAPIKeyAuth+from litellm.proxy.auth.user_api_key_auth import user_api_key_auth+from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing+from litellm.proxy.common_utils.openai_endpoint_utils import (+ get_custom_llm_provider_from_request_body,+ get_custom_llm_provider_from_request_headers,+ get_custom_llm_provider_from_request_query,+)+from litellm.proxy.vector_store_endpoints.utils import (+ is_allowed_to_call_vector_store_files_endpoint,+)+from litellm.types.utils import LlmProviders++router = APIRouter()+++def _update_request_data_with_litellm_managed_vector_store_registry(+ data: Dict,+ vector_store_id: str,+) -> Dict:+ if litellm.vector_store_registry is not None:+ vector_store_to_run = (+ litellm.vector_store_registry.get_litellm_managed_vector_store_from_registry(+ vector_store_id=vector_store_id+ )+ )+ if vector_store_to_run is not None:+ if "custom_llm_provider" in vector_store_to_run:+ data["custom_llm_provider"] = vector_store_to_run.get(+ "custom_llm_provider"+ )+ if "litellm_credential_name" in vector_store_to_run:+ data["litellm_credential_name"] = vector_store_to_run.get(+ "litellm_credential_name"+ )+ if "litellm_params" in vector_store_to_run:+ litellm_params = vector_store_to_run.get("litellm_params", {}) or {}+ data.update(litellm_params)+ return data+++async def _resolve_provider(+ *,+ data: Dict,+ request: Request,+) -> Optional[LlmProviders]:+ provider = (+ data.get("custom_llm_provider")+ or get_custom_llm_provider_from_request_headers(request=request)+ or get_custom_llm_provider_from_request_query(request=request)+ )++ if provider is None and request.method in {"POST", "PUT", "PATCH"}:+ provider = await get_custom_llm_provider_from_request_body(request=request)++ if provider is None:+ provider = "openai"++ try:+ return LlmProviders(provider)+ except Exception:+ return None+++def _maybe_check_permissions(+ *,+ provider: Optional[LlmProviders],+ vector_store_id: str,+ request: Request,+ user_api_key_dict: UserAPIKeyAuth,+) -> None:+ if provider is None:+ return+ metadata = user_api_key_dict.metadata or {}+ team_metadata = user_api_key_dict.team_metadata or {}+ if not metadata.get("allowed_vector_store_indexes") and not team_metadata.get(+ "allowed_vector_store_indexes"+ ):+ return+ is_allowed_to_call_vector_store_files_endpoint(+ provider=provider,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+++ "/v1/vector_stores/{vector_store_id}/files",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_create(+ vector_store_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ _read_request_body,+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ data = await _read_request_body(request=request)+ if "vector_store_id" not in data:+ data["vector_store_id"] = vector_store_id++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_create",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )+++ "/v1/vector_stores/{vector_store_id}/files",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_list(+ vector_store_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ query_params = dict(request.query_params)+ data: Dict[str, Optional[str]] = {"vector_store_id": vector_store_id}+ data.update(query_params)++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_list",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )+++ "/v1/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_retrieve(+ vector_store_id: str,+ file_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ data: Dict[str, str] = {+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ }++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_retrieve",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )+++ "/v1/vector_stores/{vector_store_id}/files/{file_id}/content",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files/{file_id}/content",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_content(+ vector_store_id: str,+ file_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ data: Dict[str, str] = {+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ }++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_content",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )+++ "/v1/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_update(+ vector_store_id: str,+ file_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ _read_request_body,+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ data = await _read_request_body(request=request)+ data["vector_store_id"] = vector_store_id+ data["file_id"] = file_id++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_update",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )+++ "/v1/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+ "/vector_stores/{vector_store_id}/files/{file_id}",+ dependencies=[Depends(user_api_key_auth)],+ response_class=ORJSONResponse,+ tags=["vector_store_files"],+)+async def vector_store_file_delete(+ vector_store_id: str,+ file_id: str,+ request: Request,+ fastapi_response: Response,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+):+ from litellm.proxy.proxy_server import (+ general_settings,+ llm_router,+ proxy_config,+ proxy_logging_obj,+ select_data_generator,+ user_api_base,+ user_max_tokens,+ user_model,+ user_request_timeout,+ user_temperature,+ version,+ )++ data: Dict[str, str] = {+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ }++ data = _update_request_data_with_litellm_managed_vector_store_registry(+ data=data, vector_store_id=vector_store_id+ )++ provider_enum = await _resolve_provider(data=data, request=request)++ _maybe_check_permissions(+ provider=provider_enum,+ vector_store_id=vector_store_id,+ request=request,+ user_api_key_dict=user_api_key_dict,+ )+ if provider_enum is not None and "custom_llm_provider" not in data:+ data["custom_llm_provider"] = provider_enum.value++ processor = ProxyBaseLLMRequestProcessing(data=data)+ try:+ return await processor.base_process_llm_request(+ request=request,+ fastapi_response=fastapi_response,+ user_api_key_dict=user_api_key_dict,+ route_type="avector_store_file_delete",+ proxy_logging_obj=proxy_logging_obj,+ llm_router=llm_router,+ general_settings=general_settings,+ proxy_config=proxy_config,+ select_data_generator=select_data_generator,+ model=None,+ user_model=user_model,+ user_temperature=user_temperature,+ user_request_timeout=user_request_timeout,+ user_max_tokens=user_max_tokens,+ user_api_base=user_api_base,+ version=version,+ )+ except Exception as e: # noqa: BLE001+ raise await processor._handle_llm_api_exception(+ e=e,+ user_api_key_dict=user_api_key_dict,+ proxy_logging_obj=proxy_logging_obj,+ version=version,+ )diff --git a/litellm/responses/utils.py b/litellm/responses/utils.pyindex 63c15e21a88..7798a7573d1 100644--- a/litellm/responses/utils.py+++ b/litellm/responses/utils.py@@ -147,9 +147,11 @@ class ResponsesAPIRequestUtils:if "metadata" in non_default_params:from litellm.utils import add_openai_metadata- non_default_params["metadata"] = add_openai_metadata(- non_default_params["metadata"]- )+ converted_metadata = add_openai_metadata(non_default_params["metadata"])+ if converted_metadata is not None:+ non_default_params["metadata"] = converted_metadata+ else:+ non_default_params.pop("metadata", None)return cast(ResponsesAPIOptionalRequestParams, non_default_params)diff --git a/litellm/router.py b/litellm/router.pyindex 3537cacf0c7..64c663f8ab1 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -849,6 +849,57 @@ class Router:create, call_type="vector_store_create")+ from litellm.vector_store_files.main import (+ acreate as avector_store_file_create_fn,+ alist as avector_store_file_list_fn,+ aretrieve as avector_store_file_retrieve_fn,+ aretrieve_content as avector_store_file_content_fn,+ aupdate as avector_store_file_update_fn,+ adelete as avector_store_file_delete_fn,+ create as vector_store_file_create_fn,+ list as vector_store_file_list_fn,+ retrieve as vector_store_file_retrieve_fn,+ retrieve_content as vector_store_file_content_fn,+ update as vector_store_file_update_fn,+ delete as vector_store_file_delete_fn,+ )+ self.avector_store_file_create = self.factory_function(+ avector_store_file_create_fn, call_type="avector_store_file_create"+ )+ self.vector_store_file_create = self.factory_function(+ vector_store_file_create_fn, call_type="vector_store_file_create"+ )+ self.avector_store_file_list = self.factory_function(+ avector_store_file_list_fn, call_type="avector_store_file_list"+ )+ self.vector_store_file_list = self.factory_function(+ vector_store_file_list_fn, call_type="vector_store_file_list"+ )+ self.avector_store_file_retrieve = self.factory_function(+ avector_store_file_retrieve_fn, call_type="avector_store_file_retrieve"+ )+ self.vector_store_file_retrieve = self.factory_function(+ vector_store_file_retrieve_fn, call_type="vector_store_file_retrieve"+ )+ self.avector_store_file_content = self.factory_function(+ avector_store_file_content_fn, call_type="avector_store_file_content"+ )+ self.vector_store_file_content = self.factory_function(+ vector_store_file_content_fn, call_type="vector_store_file_content"+ )+ self.avector_store_file_update = self.factory_function(+ avector_store_file_update_fn, call_type="avector_store_file_update"+ )+ self.vector_store_file_update = self.factory_function(+ vector_store_file_update_fn, call_type="vector_store_file_update"+ )+ self.avector_store_file_delete = self.factory_function(+ avector_store_file_delete_fn, call_type="avector_store_file_delete"+ )+ self.vector_store_file_delete = self.factory_function(+ vector_store_file_delete_fn, call_type="vector_store_file_delete"+ )+from litellm.google_genai import (agenerate_content,agenerate_content_stream,@@ -3685,8 +3736,20 @@ class Router:"generate_content_stream","avector_store_search","avector_store_create",+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete","vector_store_search","vector_store_create",+ "vector_store_file_create",+ "vector_store_file_list",+ "vector_store_file_retrieve",+ "vector_store_file_content",+ "vector_store_file_update",+ "vector_store_file_delete","aocr","ocr","asearch",@@ -3738,7 +3801,6 @@ class Router:"retrieve_container","delete_container",):-def sync_wrapper(custom_llm_provider: Optional[str] = None,client: Optional[Any] = None,@@ -3750,6 +3812,28 @@ class Router:return sync_wrapper+ if call_type in (+ "vector_store_file_create",+ "vector_store_file_list",+ "vector_store_file_retrieve",+ "vector_store_file_content",+ "vector_store_file_update",+ "vector_store_file_delete",+ ):++ def vector_store_file_sync_wrapper(+ custom_llm_provider: Optional[str] = None,+ client: Optional[Any] = None,+ **kwargs,+ ):+ return original_function(+ custom_llm_provider=custom_llm_provider,+ client=client,+ **kwargs,+ )++ return vector_store_file_sync_wrapper+# Handle asynchronous call typesasync def async_wrapper(custom_llm_provider: Optional[str] = None,@@ -3772,6 +3856,19 @@ class Router:original_function=original_function,**kwargs,)+ elif call_type in (+ "avector_store_file_create",+ "avector_store_file_list",+ "avector_store_file_retrieve",+ "avector_store_file_content",+ "avector_store_file_update",+ "avector_store_file_delete",+ ):+ return await self._init_vector_store_api_endpoints(+ original_function=original_function,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )elif call_type in ("anthropic_messages","aresponses",@@ -3794,7 +3891,7 @@ class Router:"acreate_container","alist_containers","aretrieve_container",- "adelete_container",+ "adelete_container"):return await self._ageneric_api_call_with_fallbacks(original_function=original_function,diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex bc7641aaf68..9d419c76f17 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -290,6 +290,18 @@ class CallTypes(str, Enum):avideo_retrieve_job = "avideo_retrieve_job"video_delete = "video_delete"avideo_delete = "avideo_delete"+ vector_store_file_create = "vector_store_file_create"+ avector_store_file_create = "avector_store_file_create"+ vector_store_file_list = "vector_store_file_list"+ avector_store_file_list = "avector_store_file_list"+ vector_store_file_retrieve = "vector_store_file_retrieve"+ avector_store_file_retrieve = "avector_store_file_retrieve"+ vector_store_file_content = "vector_store_file_content"+ avector_store_file_content = "avector_store_file_content"+ vector_store_file_update = "vector_store_file_update"+ avector_store_file_update = "avector_store_file_update"+ vector_store_file_delete = "vector_store_file_delete"+ avector_store_file_delete = "avector_store_file_delete"########################################################## Container Call Types@@ -365,6 +377,18 @@ CallTypesLiteral = Literal["aocr","avector_store_search","vector_store_search",+ "vector_store_file_create",+ "avector_store_file_create",+ "vector_store_file_list",+ "avector_store_file_list",+ "vector_store_file_retrieve",+ "avector_store_file_retrieve",+ "vector_store_file_content",+ "avector_store_file_content",+ "vector_store_file_update",+ "avector_store_file_update",+ "vector_store_file_delete",+ "avector_store_file_delete","call_mcp_tool",]diff --git a/litellm/types/vector_store_files.py b/litellm/types/vector_store_files.pynew file mode 100644index 00000000000..4e587a3ca24--- /dev/null+++ b/litellm/types/vector_store_files.py@@ -0,0 +1,88 @@+from enum import Enum+from typing import Any, Dict, List, Literal, Optional, Tuple, Union++from pydantic import BaseModel+from typing_extensions import TypedDict+++class VectorStoreFileStatus(str, Enum):+ IN_PROGRESS = "in_progress"+ COMPLETED = "completed"+ FAILED = "failed"+ CANCELLED = "cancelled"+++class VectorStoreFileChunkingStrategyType(str, Enum):+ AUTO = "auto"+ STATIC = "static"+++class VectorStoreFileStaticChunkingConfig(TypedDict, total=False):+ max_chunk_size_tokens: int+ chunk_overlap_tokens: int+++class VectorStoreFileChunkingStrategy(TypedDict, total=False):+ type: Literal["auto", "static"]+ static: Optional[VectorStoreFileStaticChunkingConfig]+++class VectorStoreFileObject(TypedDict, total=False):+ id: str+ object: Literal["vector_store.file"]+ created_at: int+ usage_bytes: Optional[int]+ vector_store_id: str+ status: VectorStoreFileStatus+ last_error: Optional[Dict[str, Any]]+ chunking_strategy: Optional[VectorStoreFileChunkingStrategy]+ attributes: Optional[Dict[str, Union[str, int, float, bool]]]+++class VectorStoreFileCreateRequest(TypedDict, total=False):+ file_id: str+ attributes: Optional[Dict[str, Union[str, int, float, bool]]]+ chunking_strategy: Optional[VectorStoreFileChunkingStrategy]+++class VectorStoreFileUpdateRequest(TypedDict, total=False):+ attributes: Dict[str, Union[str, int, float, bool]]+++class VectorStoreFileListQueryParams(TypedDict, total=False):+ after: Optional[str]+ before: Optional[str]+ filter: Optional[Literal["in_progress", "completed", "failed", "cancelled"]]+ limit: Optional[int]+ order: Optional[Literal["asc", "desc"]]+++class VectorStoreFileListResponse(TypedDict, total=False):+ object: Literal["list"]+ data: List[VectorStoreFileObject]+ first_id: Optional[str]+ last_id: Optional[str]+ has_more: bool+++class VectorStoreFileDeleteResponse(TypedDict, total=False):+ id: str+ object: Literal["vector_store.file.deleted"]+ deleted: bool+++class VectorStoreFileContentTextPart(TypedDict, total=False):+ type: Literal["text"]+ text: str+++class VectorStoreFileContentResponse(TypedDict, total=False):+ file_id: str+ filename: Optional[str]+ attributes: Optional[Dict[str, Union[str, int, float, bool]]]+ content: List[VectorStoreFileContentTextPart]+++class VectorStoreFileAuthCredentials(TypedDict, total=False):+ headers: Dict[str, Any]+ query_params: Dict[str, Any]diff --git a/litellm/utils.py b/litellm/utils.pyindex e0cfa6202ad..783d462a7af 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -230,6 +230,7 @@ from typing import (Iterable,List,Literal,+ Mapping,Optional,Tuple,Type,@@ -273,6 +274,9 @@ from litellm.llms.base_llm.realtime.transformation import BaseRealtimeConfigfrom litellm.llms.base_llm.rerank.transformation import BaseRerankConfigfrom litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfigfrom litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfig+from litellm.llms.base_llm.vector_store_files.transformation import (+ BaseVectorStoreFilesConfig,+)from litellm.llms.base_llm.videos.transformation import BaseVideoConfigfrom ._logging import _is_debugging_on, verbose_logger@@ -7571,6 +7575,18 @@ class ProviderConfigManager:return MilvusVectorStoreConfig()return None+ @staticmethod+ def get_provider_vector_store_files_config(+ provider: LlmProviders,+ ) -> Optional[BaseVectorStoreFilesConfig]:+ if litellm.LlmProviders.OPENAI == provider:+ from litellm.llms.openai.vector_store_files.transformation import (+ OpenAIVectorStoreFilesConfig,+ )++ return OpenAIVectorStoreFilesConfig()+ return None+@staticmethoddef get_provider_image_generation_config(model: str,@@ -8024,7 +8040,7 @@ def get_non_default_transcription_params(kwargs: dict) -> dict:return non_default_params-def add_openai_metadata(metadata: dict) -> dict:+def add_openai_metadata(metadata: Optional[Mapping[str, Any]]) -> Optional[Dict[str, str]]:"""Add metadata to openai optional parameters, excluding hidden params.@@ -8040,10 +8056,10 @@ def add_openai_metadata(metadata: dict) -> dict:if metadata is None:return None# Only include non-hidden parameters- visible_metadata = {- k: v+ visible_metadata: Dict[str, str] = {+ str(k): vfor k, v in metadata.items()- if k != "hidden_params" and isinstance(v, (str))+ if k != "hidden_params" and isinstance(v, str)}# max 16 keys allowed by openai - trim down to 16diff --git a/litellm/vector_store_files/__init__.py b/litellm/vector_store_files/__init__.pynew file mode 100644index 00000000000..07c66de3678--- /dev/null+++ b/litellm/vector_store_files/__init__.py@@ -0,0 +1,29 @@+from .main import (+ acreate,+ adelete,+ alist,+ aretrieve,+ aretrieve_content,+ aupdate,+ create,+ delete,+ list,+ retrieve,+ retrieve_content,+ update,+)++__all__ = [+ "create",+ "acreate",+ "list",+ "alist",+ "retrieve",+ "aretrieve",+ "retrieve_content",+ "aretrieve_content",+ "update",+ "aupdate",+ "delete",+ "adelete",+]diff --git a/litellm/vector_store_files/main.py b/litellm/vector_store_files/main.pynew file mode 100644index 00000000000..7d8fbbcd5f6--- /dev/null+++ b/litellm/vector_store_files/main.py@@ -0,0 +1,780 @@+"""LiteLLM SDK functions for managing vector store files."""++import asyncio+import contextvars+from functools import partial+from typing import Any, Coroutine, Dict, Optional, Union++import httpx++import litellm+from litellm.constants import request_timeout+from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj+from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler+from litellm.types.router import GenericLiteLLMParams+from litellm.types.utils import LlmProviders+from litellm.types.vector_store_files import (+ VectorStoreFileContentResponse,+ VectorStoreFileCreateRequest,+ VectorStoreFileDeleteResponse,+ VectorStoreFileListQueryParams,+ VectorStoreFileListResponse,+ VectorStoreFileObject,+ VectorStoreFileUpdateRequest,+)+from litellm.utils import ProviderConfigManager, client+from litellm.vector_store_files.utils import VectorStoreFileRequestUtils++base_llm_http_handler = BaseLLMHTTPHandler()++VectorStoreFileAttributeValue = Union[str, int, float, bool]+VectorStoreFileAttributes = Dict[str, VectorStoreFileAttributeValue]+++def _ensure_provider(custom_llm_provider: Optional[str]) -> str:+ return custom_llm_provider or "openai"+++def _prepare_registry_credentials(+ *,+ vector_store_id: str,+ kwargs: Dict[str, Any],+) -> None:+ if litellm.vector_store_registry is None:+ return+ try:+ registry_credentials = (+ litellm.vector_store_registry.get_credentials_for_vector_store(+ vector_store_id+ )+ )+ if registry_credentials:+ kwargs.update(registry_credentials)+ except Exception:+ pass+++@client+async def acreate(+ *,+ vector_store_id: str,+ file_id: str,+ attributes: Optional[VectorStoreFileAttributes] = None,+ chunking_strategy: Optional[Dict[str, Any]] = None,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileObject:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["acreate"] = True++ func = partial(+ create,+ vector_store_id=vector_store_id,+ file_id=file_id,+ attributes=attributes,+ chunking_strategy=chunking_strategy,+ extra_headers=extra_headers,+ extra_query=extra_query,+ extra_body=extra_body,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )++ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)++ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def create(+ *,+ vector_store_id: str,+ file_id: str,+ attributes: Optional[VectorStoreFileAttributes] = None,+ chunking_strategy: Optional[Dict[str, Any]] = None,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("acreate", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file create is not supported for {custom_llm_provider}"+ )++ local_vars.update(kwargs)+ create_request: VectorStoreFileCreateRequest = (+ VectorStoreFileRequestUtils.get_create_request_params(local_vars)+ )+ create_request["file_id"] = file_id++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={+ "vector_store_id": vector_store_id,+ **create_request,+ },+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_create_handler(+ vector_store_id=vector_store_id,+ create_request=create_request,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+async def alist(+ *,+ vector_store_id: str,+ after: Optional[str] = None,+ before: Optional[str] = None,+ filter: Optional[str] = None,+ limit: Optional[int] = None,+ order: Optional[str] = None,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileListResponse:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["alist"] = True++ func = partial(+ list,+ vector_store_id=vector_store_id,+ after=after,+ before=before,+ filter=filter,+ limit=limit,+ order=order,+ extra_headers=extra_headers,+ extra_query=extra_query,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )++ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def list(+ *,+ vector_store_id: str,+ after: Optional[str] = None,+ before: Optional[str] = None,+ filter: Optional[str] = None,+ limit: Optional[int] = None,+ order: Optional[str] = None,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_query: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[VectorStoreFileListResponse, Coroutine[Any, Any, VectorStoreFileListResponse]]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("alist", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file list is not supported for {custom_llm_provider}"+ )++ local_vars.update(kwargs)+ list_query: VectorStoreFileListQueryParams = (+ VectorStoreFileRequestUtils.get_list_query_params(local_vars)+ )++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={"vector_store_id": vector_store_id, **list_query},+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_list_handler(+ vector_store_id=vector_store_id,+ query_params=list_query,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ extra_query=extra_query,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+async def aretrieve(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileObject:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["aretrieve"] = True++ func = partial(+ retrieve,+ vector_store_id=vector_store_id,+ file_id=file_id,+ extra_headers=extra_headers,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )++ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def retrieve(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("aretrieve", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file retrieve is not supported for {custom_llm_provider}"+ )++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ },+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_retrieve_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+async def aretrieve_content(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileContentResponse:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["aretrieve_content"] = True++ func = partial(+ retrieve_content,+ vector_store_id=vector_store_id,+ file_id=file_id,+ extra_headers=extra_headers,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )+ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def retrieve_content(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[+ VectorStoreFileContentResponse, Coroutine[Any, Any, VectorStoreFileContentResponse]+]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("aretrieve_content", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file content retrieve is not supported for {custom_llm_provider}"+ )++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ },+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_content_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+async def aupdate(+ *,+ vector_store_id: str,+ file_id: str,+ attributes: VectorStoreFileAttributes,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileObject:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["aupdate"] = True++ func = partial(+ update,+ vector_store_id=vector_store_id,+ file_id=file_id,+ attributes=attributes,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )+ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def update(+ *,+ vector_store_id: str,+ file_id: str,+ attributes: VectorStoreFileAttributes,+ extra_headers: Optional[Dict[str, Any]] = None,+ extra_body: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[VectorStoreFileObject, Coroutine[Any, Any, VectorStoreFileObject]]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("aupdate", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file update is not supported for {custom_llm_provider}"+ )++ local_vars.update(kwargs)+ update_request: VectorStoreFileUpdateRequest = (+ VectorStoreFileRequestUtils.get_update_request_params(local_vars)+ )+ update_request["attributes"] = attributes++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ **update_request,+ },+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_update_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ update_request=update_request,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+async def adelete(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> VectorStoreFileDeleteResponse:+ local_vars = locals()+ try:+ loop = asyncio.get_event_loop()+ kwargs["adelete"] = True++ func = partial(+ delete,+ vector_store_id=vector_store_id,+ file_id=file_id,+ extra_headers=extra_headers,+ timeout=timeout,+ custom_llm_provider=custom_llm_provider,+ **kwargs,+ )+ ctx = contextvars.copy_context()+ func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )+++@client+def delete(+ *,+ vector_store_id: str,+ file_id: str,+ extra_headers: Optional[Dict[str, Any]] = None,+ timeout: Optional[Union[float, httpx.Timeout]] = None,+ custom_llm_provider: Optional[str] = None,+ **kwargs,+) -> Union[+ VectorStoreFileDeleteResponse, Coroutine[Any, Any, VectorStoreFileDeleteResponse]+]:+ local_vars = locals()+ try:+ litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore+ litellm_call_id: Optional[str] = kwargs.get("litellm_call_id")+ _is_async = kwargs.pop("adelete", False) is True++ custom_llm_provider = _ensure_provider(custom_llm_provider)++ _prepare_registry_credentials(vector_store_id=vector_store_id, kwargs=kwargs)++ litellm_params = GenericLiteLLMParams(+ vector_store_id=vector_store_id, **kwargs+ )++ provider_config = ProviderConfigManager.get_provider_vector_store_files_config(+ provider=LlmProviders(custom_llm_provider)+ )+ if provider_config is None:+ raise ValueError(+ f"Vector store file delete is not supported for {custom_llm_provider}"+ )++ litellm_logging_obj.update_environment_variables(+ model=None,+ optional_params={+ "vector_store_id": vector_store_id,+ "file_id": file_id,+ },+ litellm_params={+ "vector_store_id": vector_store_id,+ "litellm_call_id": litellm_call_id,+ **litellm_params.model_dump(exclude_none=True),+ },+ custom_llm_provider=custom_llm_provider,+ )++ response = base_llm_http_handler.vector_store_file_delete_handler(+ vector_store_id=vector_store_id,+ file_id=file_id,+ vector_store_files_provider_config=provider_config,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ timeout=timeout or request_timeout,+ client=kwargs.get("client"),+ _is_async=_is_async,+ )+ return response+ except Exception as e: # noqa: BLE001+ raise litellm.exception_type(+ model=None,+ custom_llm_provider=custom_llm_provider,+ original_exception=e,+ completion_kwargs=local_vars,+ extra_kwargs=kwargs,+ )diff --git a/litellm/vector_store_files/utils.py b/litellm/vector_store_files/utils.pynew file mode 100644index 00000000000..cfc932f0cb7--- /dev/null+++ b/litellm/vector_store_files/utils.py@@ -0,0 +1,47 @@+from typing import Any, Dict, cast, get_type_hints++from litellm.types.vector_store_files import (+ VectorStoreFileCreateRequest,+ VectorStoreFileListQueryParams,+ VectorStoreFileUpdateRequest,+)+++class VectorStoreFileRequestUtils:+ """Helper utilities for constructing vector store file requests."""++ @staticmethod+ def _filter_params(params: Dict[str, Any], model: Any) -> Dict[str, Any]:+ valid_keys = get_type_hints(model).keys()+ return {+ key: value+ for key, value in params.items()+ if key in valid_keys and value is not None+ }++ @staticmethod+ def get_create_request_params(+ params: Dict[str, Any]+ ) -> VectorStoreFileCreateRequest:+ filtered = VectorStoreFileRequestUtils._filter_params(+ params=params, model=VectorStoreFileCreateRequest+ )+ return cast(VectorStoreFileCreateRequest, filtered)++ @staticmethod+ def get_list_query_params(+ params: Dict[str, Any]+ ) -> VectorStoreFileListQueryParams:+ filtered = VectorStoreFileRequestUtils._filter_params(+ params=params, model=VectorStoreFileListQueryParams+ )+ return cast(VectorStoreFileListQueryParams, filtered)++ @staticmethod+ def get_update_request_params(+ params: Dict[str, Any]+ ) -> VectorStoreFileUpdateRequest:+ filtered = VectorStoreFileRequestUtils._filter_params(+ params=params, model=VectorStoreFileUpdateRequest+ )+ return cast(VectorStoreFileUpdateRequest, filtered)diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 0fe71e4541e..367f788dd34 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -8515,10 +8515,18 @@"/v1/images/generations"]},+ "fal_ai/fal-ai/flux-pro/v1.1": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.04,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },"fal_ai/fal-ai/flux-pro/v1.1-ultra": {"litellm_provider": "fal_ai","mode": "image_generation",- "output_cost_per_image": 0.0398,+ "output_cost_per_image": 0.06,"supported_endpoints": ["/v1/images/generations"]@@ -8531,6 +8539,30 @@"/v1/images/generations"]},+ "fal_ai/fal-ai/bytedance/seedream/v3/text-to-image": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.03,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },+ "fal_ai/fal-ai/bytedance/dreamina/v3.1/text-to-image": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.03,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },+ "fal_ai/fal-ai/ideogram/v3": {+ "litellm_provider": "fal_ai",+ "mode": "image_generation",+ "output_cost_per_image": 0.06,+ "supported_endpoints": [+ "/v1/images/generations"+ ]+ },"fal_ai/fal-ai/imagen4/preview": {"litellm_provider": "fal_ai","mode": "image_generation",diff --git a/tests/image_gen_tests/test_fal_ai_image_generation.py b/tests/image_gen_tests/test_fal_ai_image_generation.pyindex 7b5415e1d72..2db1aeefead 100644--- a/tests/image_gen_tests/test_fal_ai_image_generation.py+++ b/tests/image_gen_tests/test_fal_ai_image_generation.py@@ -14,8 +14,12 @@ from litellm import aimage_generation"model",["fal_ai/fal-ai/flux-pro/v1.1-ultra",+ "fal_ai/fal-ai/flux-pro/v1.1","fal_ai/fal-ai/flux/schnell",+ "fal_ai/fal-ai/bytedance/seedream/v3/text-to-image",+ "fal_ai/fal-ai/bytedance/dreamina/v3.1/text-to-image","fal_ai/fal-ai/recraft/v3/text-to-image",+ "fal_ai/fal-ai/ideogram/v3","fal_ai/bria/text-to-image/3.2","fal_ai/fal-ai/stable-diffusion-v35-medium"],diff --git a/tests/test_litellm/llms/azure/test_azure_common_utils.py b/tests/test_litellm/llms/azure/test_azure_common_utils.pyindex 308d5d9fed9..1c81f12e0fe 100644--- a/tests/test_litellm/llms/azure/test_azure_common_utils.py+++ b/tests/test_litellm/llms/azure/test_azure_common_utils.py@@ -570,7 +570,9 @@ async def test_ensure_initialize_azure_sdk_client_always_used(call_type):):# Skip container call types as they're not supported for Azure (only OpenAI)pytest.skip(f"Skipping {call_type.value} because Azure doesn't support container operations")-+ elif call_type == CallTypes.avector_store_file_create or call_type == CallTypes.avector_store_file_list or call_type == CallTypes.avector_store_file_retrieve or call_type == CallTypes.avector_store_file_content or call_type == CallTypes.avector_store_file_update or call_type == CallTypes.avector_store_file_delete:+ # Skip vector store file call types as they're not supported for Azure (only OpenAI)+ pytest.skip(f"Skipping {call_type.value} because Azure doesn't support vector store file operations")# Mock the initialize_azure_sdk_client functionwith patch(patch_target) as mock_init_azure:# Also mock async_function_with_fallbacks to prevent actual API callsdiff --git a/tests/test_litellm/llms/openai/vector_store_files/test_openai_vector_store_files_transformation.py b/tests/test_litellm/llms/openai/vector_store_files/test_openai_vector_store_files_transformation.pynew file mode 100644index 00000000000..a8e07cd3645--- /dev/null+++ b/tests/test_litellm/llms/openai/vector_store_files/test_openai_vector_store_files_transformation.py@@ -0,0 +1,112 @@+import httpx+import pytest++from litellm.llms.openai.vector_store_files.transformation import (+ OpenAIVectorStoreFilesConfig,+)+from litellm.types.router import GenericLiteLLMParams+++def config() -> OpenAIVectorStoreFilesConfig:+ return OpenAIVectorStoreFilesConfig()+++def test_validate_environment_sets_headers(config: OpenAIVectorStoreFilesConfig):+ headers: dict = {}+ params = GenericLiteLLMParams(api_key="sk-test")++ result = config.validate_environment(headers=headers, litellm_params=params)++ assert result["Authorization"] == "Bearer sk-test"+ assert result[config.ASSISTANTS_HEADER_KEY] == config.ASSISTANTS_HEADER_VALUE+ assert result["Content-Type"] == "application/json"+++def test_get_complete_url(config: OpenAIVectorStoreFilesConfig):+ url = config.get_complete_url(+ api_base="https://api.example.com/v1",+ vector_store_id="vs_123",+ litellm_params={},+ )+ assert url == "https://api.example.com/v1/vector_stores/vs_123/files"+++def test_transform_create_request(config: OpenAIVectorStoreFilesConfig):+ api_base = "https://api.example.com/v1/vector_stores/vs_123/files"+ url, payload = config.transform_create_vector_store_file_request(+ vector_store_id="vs_123",+ create_request={+ "file_id": "file-abc",+ "attributes": {"key": "value"},+ },+ api_base=api_base,+ )++ assert url == api_base+ assert payload["file_id"] == "file-abc"+ assert payload["attributes"]["key"] == "value"+++def test_transform_list_request(config: OpenAIVectorStoreFilesConfig):+ api_base = "https://api.example.com/v1/vector_stores/vs_123/files"+ url, params = config.transform_list_vector_store_files_request(+ vector_store_id="vs_123",+ query_params={"limit": 2, "order": "asc"},+ api_base=api_base,+ )++ assert url == api_base+ assert params == {"limit": 2, "order": "asc"}+++def test_transform_create_response(config: OpenAIVectorStoreFilesConfig):+ response = httpx.Response(+ status_code=200,+ json={+ "id": "file-abc",+ "object": "vector_store.file",+ "vector_store_id": "vs_123",+ "status": "completed",+ "created_at": 123,+ },+ )++ result = config.transform_create_vector_store_file_response(response=response)+ assert result["id"] == "file-abc"+ assert result["status"] == "completed"+++def test_transform_list_response(config: OpenAIVectorStoreFilesConfig):+ response = httpx.Response(+ status_code=200,+ json={+ "object": "list",+ "data": [+ {+ "id": "file-abc",+ "object": "vector_store.file",+ "vector_store_id": "vs_123",+ "status": "completed",+ "created_at": 123,+ }+ ],+ "first_id": "file-abc",+ "last_id": "file-abc",+ "has_more": False,+ },+ )++ result = config.transform_list_vector_store_files_response(response=response)+ assert result["data"][0]["id"] == "file-abc"+ assert result["has_more"] is False+++def test_transform_delete_response(config: OpenAIVectorStoreFilesConfig):+ response = httpx.Response(+ status_code=200,+ json={"id": "file-abc", "object": "vector_store.file.deleted", "deleted": True},+ )++ result = config.transform_delete_vector_store_file_response(response=response)+ assert result["deleted"] is Truediff --git a/tests/test_litellm/proxy/vector_store_endpoints/test_vector_store_endpoints.py b/tests/test_litellm/proxy/vector_store_endpoints/test_vector_store_endpoints.pyindex 437b71535ba..20f9eefaf3f 100644--- a/tests/test_litellm/proxy/vector_store_endpoints/test_vector_store_endpoints.py+++ b/tests/test_litellm/proxy/vector_store_endpoints/test_vector_store_endpoints.py@@ -22,6 +22,7 @@ from litellm.proxy.vector_store_endpoints.endpoints import (from litellm.proxy.vector_store_endpoints.utils import (check_vector_store_permission,is_allowed_to_call_vector_store_endpoint,+ is_allowed_to_call_vector_store_files_endpoint,)from litellm.types.utils import LlmProviders@@ -60,6 +61,51 @@ async def test_router_avector_store_search_passes_correct_args():assert call_args[1]["custom_llm_provider"] == "bedrock"+async def test_router_avector_store_file_list_passes_correct_args():+ with patch(+ "litellm.vector_store_files.main.alist",+ new=AsyncMock(return_value={"object": "list", "data": []}),+ ) as mock_alist:+ router = litellm.Router(model_list=[])++ result = await router.avector_store_file_list(+ vector_store_id="test_store_id",+ limit=5,+ order="asc",+ custom_llm_provider="openai",+ )++ assert result == {"object": "list", "data": []}+ mock_alist.assert_called_once()+ call_kwargs = mock_alist.call_args.kwargs+ assert call_kwargs["vector_store_id"] == "test_store_id"+ assert call_kwargs["limit"] == 5+ assert call_kwargs["order"] == "asc"+ assert call_kwargs["custom_llm_provider"] == "openai"+++def test_router_vector_store_file_delete_passes_correct_args():+ with patch(+ "litellm.vector_store_files.main.delete",+ return_value={"deleted": True},+ ) as mock_delete:+ router = litellm.Router(model_list=[])++ result = router.vector_store_file_delete(+ vector_store_id="test_store_id",+ file_id="file-123",+ custom_llm_provider="openai",+ )++ assert result == {"deleted": True}+ mock_delete.assert_called_once()+ call_kwargs = mock_delete.call_args.kwargs+ assert call_kwargs["vector_store_id"] == "test_store_id"+ assert call_kwargs["file_id"] == "file-123"+ assert call_kwargs["custom_llm_provider"] == "openai"++def test_update_request_data_with_litellm_managed_vector_store_registry():"""Test that _update_request_data_with_litellm_managed_vector_store_registry@@ -625,3 +671,94 @@ class TestIsAllowedToCallVectorStoreEndpoint:)assert exc_info.value.status_code == 403+++class TestIsAllowedToCallVectorStoreFilesEndpoint:+ def _mock_provider_config(self):+ provider_config = MagicMock()+ provider_config.get_vector_store_file_endpoints_by_type.return_value = {+ "read": (("GET", "/vector_stores/{vector_store_id}/files"),),+ "write": (+ ("POST", "/vector_stores/{vector_store_id}/files"),+ ("DELETE", "/vector_stores/{vector_store_id}/files/{file_id}"),+ ),+ }+ return provider_config++ def test_allows_access_with_permissions(self):+ mock_request = MagicMock(spec=Request)+ mock_request.method = "GET"+ mock_request.url.path = "/v1/vector_stores/my-index/files"++ mock_user_api_key = MagicMock(spec=UserAPIKeyAuth)+ mock_user_api_key.user_role = None+ mock_user_api_key.metadata = {+ "allowed_vector_store_indexes": [+ {"index_name": "my-index", "index_permissions": ["read", "write"]}+ ]+ }+ mock_user_api_key.team_metadata = None++ with patch(+ "litellm.proxy.vector_store_endpoints.utils.ProviderConfigManager.get_provider_vector_store_files_config",+ return_value=self._mock_provider_config(),+ ):+ result = is_allowed_to_call_vector_store_files_endpoint(+ provider=LlmProviders.OPENAI,+ vector_store_id="my-index",+ request=mock_request,+ user_api_key_dict=mock_user_api_key,+ )++ assert result is True++ def test_raises_when_permission_missing(self):+ mock_request = MagicMock(spec=Request)+ mock_request.method = "POST"+ mock_request.url.path = "/v1/vector_stores/my-index/files"++ mock_user_api_key = MagicMock(spec=UserAPIKeyAuth)+ mock_user_api_key.user_role = None+ mock_user_api_key.metadata = {+ "allowed_vector_store_indexes": [+ {"index_name": "my-index", "index_permissions": ["read"]}+ ]+ }+ mock_user_api_key.team_metadata = None++ with patch(+ "litellm.proxy.vector_store_endpoints.utils.ProviderConfigManager.get_provider_vector_store_files_config",+ return_value=self._mock_provider_config(),+ ):+ with pytest.raises(HTTPException) as exc_info:+ is_allowed_to_call_vector_store_files_endpoint(+ provider=LlmProviders.OPENAI,+ vector_store_id="my-index",+ request=mock_request,+ user_api_key_dict=mock_user_api_key,+ )++ assert exc_info.value.status_code == 403++ def test_returns_none_when_provider_not_supported(self):+ mock_request = MagicMock(spec=Request)+ mock_request.method = "GET"+ mock_request.url.path = "/v1/vector_stores/my-index/files"++ mock_user_api_key = MagicMock(spec=UserAPIKeyAuth)+ mock_user_api_key.user_role = None+ mock_user_api_key.metadata = {}+ mock_user_api_key.team_metadata = {}++ with patch(+ "litellm.proxy.vector_store_endpoints.utils.ProviderConfigManager.get_provider_vector_store_files_config",+ return_value=None,+ ):+ result = is_allowed_to_call_vector_store_files_endpoint(+ provider=LlmProviders.OPENAI,+ vector_store_id="my-index",+ request=mock_request,+ user_api_key_dict=mock_user_api_key,+ )++ assert result is None