Skip to content

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]

[Feat] Add Background mode for Responses API - OpenAI, AzureOpenAI (#11640)

Ishaan Jafff3f7bc1537ec
diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py
index 7b77ec1ef15..f6065198c39 100644
--- a/litellm/llms/openai/responses/transformation.py
+++ b/litellm/llms/openai/responses/transformation.py
@@ -36,6 +36,7 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
"previous_response_id",
"reasoning",
"store",
+ "background",
"stream",
"temperature",
"text",
diff --git a/litellm/responses/main.py b/litellm/responses/main.py
index fded67285fd..84d6a24c175 100644
--- a/litellm/responses/main.py
+++ b/litellm/responses/main.py
@@ -49,6 +49,7 @@ async def aresponses(
previous_response_id: Optional[str] = None,
reasoning: Optional[Reasoning] = None,
store: Optional[bool] = None,
+ background: Optional[bool] = None,
stream: Optional[bool] = None,
temperature: Optional[float] = None,
text: Optional[ResponseTextConfigParam] = None,
@@ -93,6 +94,7 @@ async def aresponses(
previous_response_id=previous_response_id,
reasoning=reasoning,
store=store,
+ background=background,
stream=stream,
temperature=temperature,
text=text,
@@ -148,6 +150,7 @@ def responses(
previous_response_id: Optional[str] = None,
reasoning: Optional[Reasoning] = None,
store: Optional[bool] = None,
+ background: Optional[bool] = None,
stream: Optional[bool] = None,
temperature: Optional[float] = None,
text: Optional[ResponseTextConfigParam] = None,
diff --git a/litellm/types/llms/openai.py b/litellm/types/llms/openai.py
index 7cf0474b77e..eaeda2d009b 100644
--- a/litellm/types/llms/openai.py
+++ b/litellm/types/llms/openai.py
@@ -830,12 +830,12 @@ class OpenAIChatCompletionChunk(ChatCompletionChunk):
class Hyperparameters(BaseModel):
batch_size: Optional[Union[str, int]] = None # "Number of examples in each batch."
- learning_rate_multiplier: Optional[
- Union[str, float]
- ] = None # Scaling factor for the learning rate
- n_epochs: Optional[
- Union[str, int]
- ] = None # "The number of epochs to train the model for"
+ learning_rate_multiplier: Optional[Union[str, float]] = (
+ None # Scaling factor for the learning rate
+ )
+ n_epochs: Optional[Union[str, int]] = (
+ None # "The number of epochs to train the model for"
+ )
class FineTuningJobCreate(BaseModel):
@@ -862,18 +862,18 @@ class FineTuningJobCreate(BaseModel):
model: str # "The name of the model to fine-tune."
training_file: str # "The ID of an uploaded file that contains training data."
- hyperparameters: Optional[
- Hyperparameters
- ] = None # "The hyperparameters used for the fine-tuning job."
- suffix: Optional[
- str
- ] = None # "A string of up to 18 characters that will be added to your fine-tuned model name."
- validation_file: Optional[
- str
- ] = None # "The ID of an uploaded file that contains validation data."
- integrations: Optional[
- List[str]
- ] = None # "A list of integrations to enable for your fine-tuning job."
+ hyperparameters: Optional[Hyperparameters] = (
+ None # "The hyperparameters used for the fine-tuning job."
+ )
+ suffix: Optional[str] = (
+ None # "A string of up to 18 characters that will be added to your fine-tuned model name."
+ )
+ validation_file: Optional[str] = (
+ None # "The ID of an uploaded file that contains validation data."
+ )
+ integrations: Optional[List[str]] = (
+ None # "A list of integrations to enable for your fine-tuning job."
+ )
seed: Optional[int] = None # "The seed controls the reproducibility of the job."
@@ -938,6 +938,7 @@ class ResponsesAPIOptionalRequestParams(TypedDict, total=False):
previous_response_id: Optional[str]
reasoning: Optional[Reasoning]
store: Optional[bool]
+ background: Optional[bool]
stream: Optional[bool]
temperature: Optional[float]
text: Optional[ResponseTextConfigParam]
diff --git a/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py b/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py
index 0eea8da9b92..b9b9d3981d2 100644
--- a/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py
+++ b/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py
@@ -63,7 +63,7 @@ class TestOpenAIResponsesAPIConfig:
def test_transform_responses_api_request(self):
"""Test request transformation"""
input_text = "What is the capital of France?"
- optional_params = {"temperature": 0.7, "stream": True}
+ optional_params = {"temperature": 0.7, "stream": True, "background": True}
result = self.config.transform_responses_api_request(
model=self.model,
@@ -79,6 +79,7 @@ class TestOpenAIResponsesAPIConfig:
"input": input_text,
"temperature": 0.7,
"stream": True,
+ "background": True,
}
self.validate_responses_api_request_params(result, expected_fields)