use extra_query for get request

This commit is contained in:
eycjur 2025-09-28 18:03:32 +09:00
parent 35c14f7178
commit 4f1e409082
3 changed files with 16 additions and 4 deletions

View file

@ -931,7 +931,7 @@ curl http://localhost:4000/v1/batches \
```python
retrieved_batch = client.batches.retrieve(
batch.id,
extra_body={"custom_llm_provider": "azure"}
extra_query={"custom_llm_provider": "azure"}
)
```
@ -978,7 +978,7 @@ curl http://localhost:4000/v1/batches/batch_abc123/cancel \
<TabItem value="sdk" label="OpenAI Python SDK">
```python
client.batches.list(extra_body={"custom_llm_provider": "azure"})
client.batches.list(extra_query={"custom_llm_provider": "azure"})
```
</TabItem>

View file

@ -18,6 +18,7 @@ from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessin
from litellm.proxy.common_utils.http_parsing_utils import _read_request_body
from litellm.proxy.common_utils.openai_endpoint_utils import (
get_custom_llm_provider_from_request_body,
get_custom_llm_provider_from_request_query,
)
from litellm.proxy.openai_files_endpoints.common_utils import (
_is_base64_encoded_unified_file_id,
@ -282,7 +283,7 @@ async def retrieve_batch(
else:
custom_llm_provider = (
provider
or await get_custom_llm_provider_from_request_body(request=request)
or get_custom_llm_provider_from_request_query(request=request)
or "openai"
)
response = await litellm.aretrieve_batch(
@ -392,7 +393,7 @@ async def list_batches(
else:
custom_llm_provider = (
provider
or await get_custom_llm_provider_from_request_body(request=request)
or get_custom_llm_provider_from_request_query(request=request)
or "openai"
)
response = await litellm.alist_batches(

View file

@ -38,3 +38,14 @@ async def get_custom_llm_provider_from_request_body(request: Request) -> Optiona
if "custom_llm_provider" in request_body:
return request_body["custom_llm_provider"]
return None
def get_custom_llm_provider_from_request_query(request: Request) -> Optional[str]:
"""
Get the `custom_llm_provider` from the request query parameters
Safely reads the request query parameters
"""
if "custom_llm_provider" in request.query_params:
return request.query_params["custom_llm_provider"]
return None