Skip to content

[Feat] New LLM API Endpoint - Add List input items for Responses API #11602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions litellm/llms/azure/responses/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,35 @@ def transform_get_response_api_request(
data: Dict = {}
verbose_logger.debug(f"get response url={get_url}")
return get_url, data

def transform_list_input_items_request(
self,
response_id: str,
api_base: str,
litellm_params: GenericLiteLLMParams,
headers: dict,
after: Optional[str] = None,
before: Optional[str] = None,
include: Optional[List[str]] = None,
limit: int = 20,
order: Literal["asc", "desc"] = "desc",
) -> Tuple[str, Dict]:
url = (
self._construct_url_for_response_id_in_path(
api_base=api_base, response_id=response_id
)
+ "/input_items"
)
params: Dict[str, Any] = {}
if after is not None:
params["after"] = after
if before is not None:
params["before"] = before
if include:
params["include"] = ",".join(include)
if limit is not None:
params["limit"] = limit
if order is not None:
params["order"] = order
verbose_logger.debug(f"list input items url={url}")
return url, params
30 changes: 28 additions & 2 deletions litellm/llms/base_llm/responses/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def transform_get_response_api_request(
headers: dict,
) -> Tuple[str, Dict]:
pass

@abstractmethod
def transform_get_response_api_response(
self,
Expand All @@ -165,10 +165,36 @@ def transform_get_response_api_response(
) -> ResponsesAPIResponse:
pass

#########################################################
########## LIST INPUT ITEMS API TRANSFORMATION ##########
#########################################################
@abstractmethod
def transform_list_input_items_request(
self,
response_id: str,
api_base: str,
litellm_params: GenericLiteLLMParams,
headers: dict,
after: Optional[str] = None,
before: Optional[str] = None,
include: Optional[List[str]] = None,
limit: int = 20,
order: Literal["asc", "desc"] = "desc",
) -> Tuple[str, Dict]:
pass

@abstractmethod
def transform_list_input_items_response(
self,
raw_response: httpx.Response,
logging_obj: LiteLLMLoggingObj,
) -> Dict:
pass

#########################################################
########## END GET RESPONSE API TRANSFORMATION ##########
#########################################################

def get_error_class(
self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers]
) -> BaseLLMException:
Expand Down
168 changes: 167 additions & 1 deletion litellm/llms/custom_httpx/llm_http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Coroutine,
Dict,
List,
Literal,
Optional,
Tuple,
Union,
Expand Down Expand Up @@ -1812,6 +1813,168 @@ async def async_get_responses(
logging_obj=logging_obj,
)

#####################################################################
################ LIST RESPONSES INPUT ITEMS HANDLER ###########################
#####################################################################
def list_responses_input_items(
self,
response_id: str,
responses_api_provider_config: BaseResponsesAPIConfig,
litellm_params: GenericLiteLLMParams,
logging_obj: LiteLLMLoggingObj,
custom_llm_provider: Optional[str] = None,
after: Optional[str] = None,
before: Optional[str] = None,
include: Optional[List[str]] = None,
limit: int = 20,
order: Literal["asc", "desc"] = "desc",
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[Dict, Coroutine[Any, Any, Dict]]:
if _is_async:
return self.async_list_responses_input_items(
response_id=response_id,
responses_api_provider_config=responses_api_provider_config,
litellm_params=litellm_params,
logging_obj=logging_obj,
custom_llm_provider=custom_llm_provider,
after=after,
before=before,
include=include,
limit=limit,
order=order,
extra_headers=extra_headers,
timeout=timeout,
client=client,
)

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 = responses_api_provider_config.validate_environment(
api_key=litellm_params.api_key,
headers=extra_headers or {},
model="None",
)

if extra_headers:
headers.update(extra_headers)

api_base = responses_api_provider_config.get_complete_url(
api_base=litellm_params.api_base,
litellm_params=dict(litellm_params),
)

url, params = responses_api_provider_config.transform_list_input_items_request(
response_id=response_id,
api_base=api_base,
litellm_params=litellm_params,
headers=headers,
after=after,
before=before,
include=include,
limit=limit,
order=order,
)

logging_obj.pre_call(
input="",
api_key="",
additional_args={
"complete_input_dict": params,
"api_base": api_base,
"headers": headers,
},
)

try:
response = sync_httpx_client.get(url=url, headers=headers, params=params)
except Exception as e:
raise self._handle_error(e=e, provider_config=responses_api_provider_config)

return responses_api_provider_config.transform_list_input_items_response(
raw_response=response,
logging_obj=logging_obj,
)

async def async_list_responses_input_items(
self,
response_id: str,
responses_api_provider_config: BaseResponsesAPIConfig,
litellm_params: GenericLiteLLMParams,
logging_obj: LiteLLMLoggingObj,
custom_llm_provider: Optional[str] = None,
after: Optional[str] = None,
before: Optional[str] = None,
include: Optional[List[str]] = None,
limit: int = 20,
order: Literal["asc", "desc"] = "desc",
extra_headers: Optional[Dict[str, Any]] = None,
timeout: Optional[Union[float, httpx.Timeout]] = None,
client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,
) -> Dict:
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 = responses_api_provider_config.validate_environment(
api_key=litellm_params.api_key,
headers=extra_headers or {},
model="None",
)

if extra_headers:
headers.update(extra_headers)

api_base = responses_api_provider_config.get_complete_url(
api_base=litellm_params.api_base,
litellm_params=dict(litellm_params),
)

url, params = responses_api_provider_config.transform_list_input_items_request(
response_id=response_id,
api_base=api_base,
litellm_params=litellm_params,
headers=headers,
after=after,
before=before,
include=include,
limit=limit,
order=order,
)

logging_obj.pre_call(
input="",
api_key="",
additional_args={
"complete_input_dict": params,
"api_base": api_base,
"headers": headers,
},
)

try:
response = await async_httpx_client.get(
url=url, headers=headers, params=params
)
except Exception as e:
raise self._handle_error(e=e, provider_config=responses_api_provider_config)

return responses_api_provider_config.transform_list_input_items_response(
raw_response=response,
logging_obj=logging_obj,
)

def create_file(
self,
create_file_data: CreateFileRequest,
Expand Down Expand Up @@ -2134,7 +2297,10 @@ def image_edit_handler(
_is_async: bool = False,
fake_stream: bool = False,
litellm_metadata: Optional[Dict[str, Any]] = None,
) -> Union[ImageResponse, Coroutine[Any, Any, ImageResponse],]:
) -> Union[
ImageResponse,
Coroutine[Any, Any, ImageResponse],
]:
"""

Handles image edit requests.
Expand Down
45 changes: 43 additions & 2 deletions litellm/llms/openai/responses/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def transform_delete_response_api_response(
message=raw_response.text, status_code=raw_response.status_code
)
return DeleteResponseResult(**raw_response_json)

#########################################################
########## GET RESPONSE API TRANSFORMATION ###############
#########################################################
Expand All @@ -271,7 +271,7 @@ def transform_get_response_api_request(
url = f"{api_base}/{response_id}"
data: Dict = {}
return url, data

def transform_get_response_api_response(
self,
raw_response: httpx.Response,
Expand All @@ -287,3 +287,44 @@ def transform_get_response_api_response(
message=raw_response.text, status_code=raw_response.status_code
)
return ResponsesAPIResponse(**raw_response_json)

#########################################################
########## LIST INPUT ITEMS TRANSFORMATION #############
#########################################################
def transform_list_input_items_request(
self,
response_id: str,
api_base: str,
litellm_params: GenericLiteLLMParams,
headers: dict,
after: Optional[str] = None,
before: Optional[str] = None,
include: Optional[List[str]] = None,
limit: int = 20,
order: Literal["asc", "desc"] = "desc",
) -> Tuple[str, Dict]:
url = f"{api_base}/{response_id}/input_items"
params: Dict[str, Any] = {}
if after is not None:
params["after"] = after
if before is not None:
params["before"] = before
if include:
params["include"] = ",".join(include)
if limit is not None:
params["limit"] = limit
if order is not None:
params["order"] = order
return url, params

def transform_list_input_items_response(
self,
raw_response: httpx.Response,
logging_obj: LiteLLMLoggingObj,
) -> Dict:
try:
return raw_response.json()
except Exception:
raise OpenAIError(
message=raw_response.text, status_code=raw_response.status_code
)
26 changes: 26 additions & 0 deletions litellm/model_prices_and_context_window_backup.json
Original file line number Diff line number Diff line change
Expand Up @@ -4153,6 +4153,32 @@
"supports_assistant_prefill": true,
"supports_tool_choice": true
},
"mistral/magistral-medium-2506": {
"max_tokens": 40000,
"max_input_tokens": 40000,
"max_output_tokens": 40000,
"input_cost_per_token": 2e-06,
"output_cost_per_token": 5e-06,
"litellm_provider": "mistral",
"mode": "chat",
"source": "https://mistral.ai/news/magistral",
"supports_function_calling": true,
"supports_assistant_prefill": true,
"supports_tool_choice": true
},
"mistral/magistral-small-2506": {
"max_tokens": 40000,
"max_input_tokens": 40000,
"max_output_tokens": 40000,
"input_cost_per_token": 0.0,
"output_cost_per_token": 0.0,
"litellm_provider": "mistral",
"mode": "chat",
"source": "https://mistral.ai/news/magistral",
"supports_function_calling": true,
"supports_assistant_prefill": true,
"supports_tool_choice": true
},
"mistral/mistral-embed": {
"max_tokens": 8192,
"max_input_tokens": 8192,
Expand Down
2 changes: 2 additions & 0 deletions litellm/proxy/common_request_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ async def common_processing_pre_call_logic(
"acancel_fine_tuning_job",
"alist_fine_tuning_jobs",
"aretrieve_fine_tuning_job",
"alist_input_items",
"aimage_edit",
],
version: Optional[str] = None,
Expand Down Expand Up @@ -329,6 +330,7 @@ async def base_process_llm_request(
"adelete_responses",
"atext_completion",
"aimage_edit",
"alist_input_items",
],
proxy_logging_obj: ProxyLogging,
general_settings: dict,
Expand Down
Loading
Loading