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(sdk): add litellm.systemone and trim litellm.decisions to the OpenAI shape (#45846)

devin-ai-integration[bot]25d9b0538634
diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml
index faa02c8f1a9..18df865c988 100644
--- a/.github/workflows/test-unit.yml
+++ b/.github/workflows/test-unit.yml
@@ -140,6 +140,7 @@ jobs:
tests/unit/batch_completion
tests/unit/decisions
tests/unit/litellm_core_utils
+ tests/unit/systemone
python-version: "3.12"
workers: 4
reruns: 0
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 554b37f11d4..a611b90bc37 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -1490,6 +1490,7 @@ from .rust_bridge import rust
from .rag.main import *
from .sandbox.main import *
from .decisions.main import *
+from .systemone.main import *
from .tool_loop import ToolLoopMaxRoundsExceeded, arun_tool_loop, run_tool_loop
from .search.main import *
from .realtime_api.main import (
diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py
index da420ab0578..45d98043144 100644
--- a/litellm/cost_calculator.py
+++ b/litellm/cost_calculator.py
@@ -2026,6 +2026,8 @@ def response_cost_calculator(
"asearch",
"decisions",
"adecisions",
+ "systemone",
+ "asystemone",
],
optional_params: dict,
cache_hit: bool | None = None,
diff --git a/litellm/decisions/call.py b/litellm/decisions/call.py
new file mode 100644
index 00000000000..757bc5a9b0a
--- /dev/null
+++ b/litellm/decisions/call.py
@@ -0,0 +1,347 @@
+from collections.abc import Mapping, Sequence
+from dataclasses import dataclass, field, replace
+from typing import Final, TypeAlias
+
+import httpx
+from pydantic import ConfigDict, TypeAdapter, ValidationError
+from typing_extensions import assert_never
+
+import litellm
+from litellm.litellm_core_utils.core_helpers import RESPONSE_COST_HEADER, normalize_drop_params
+from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
+from litellm.llms.base_llm.chat.transformation import BaseLLMException
+from litellm.llms.base_llm.decisions.transformation import (
+ BaseDecisionsConfig,
+ ir_to_systemone_response,
+ systemone_request_to_ir,
+)
+from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
+from litellm.llms.openai.decisions.transformation import ir_to_openai_response, openai_request_to_ir
+from litellm.types.decisions import (
+ DecisionQuestion,
+ DecisionsIRRequest,
+ DecisionsIRResponse,
+ DecisionsJSON,
+ DecisionsRequestBody,
+ DecisionsResponse,
+ OpenAIDecisionInput,
+ OpenAIDecisionQuestion,
+ OpenAIDecisionRequestBody,
+ OpenAIDecisionResponse,
+ UnsupportedDecisionsRequest,
+)
+from litellm.types.utils import LlmProviders
+from litellm.utils import ProviderConfigManager
+
+SystemOneQuestions: TypeAlias = Mapping[str, DecisionQuestion | Mapping[str, object]]
+OpenAIDecisionQuestions: TypeAlias = Sequence[OpenAIDecisionQuestion | Mapping[str, object]]
+DecisionsRequestFormat: TypeAlias = DecisionsRequestBody | OpenAIDecisionRequestBody
+
+_SYSTEMONE_REQUEST_ADAPTER: Final[TypeAdapter[DecisionsRequestBody]] = TypeAdapter(DecisionsRequestBody)
+_OPENAI_REQUEST_ADAPTER: Final[TypeAdapter[OpenAIDecisionRequestBody]] = TypeAdapter(OpenAIDecisionRequestBody)
+_SAFETY_IDENTIFIER_ADAPTER: Final[TypeAdapter[str | None]] = TypeAdapter(
+ str | None, config=ConfigDict(title="safety_identifier")
+)
+_HANDLER: Final = BaseLLMHTTPHandler()
+
+
+@dataclass(frozen=True, slots=True)
+class SystemOneRequestFields:
+ state: DecisionsJSON | None
+ questions: SystemOneQuestions | None
+
+ def validate(self, safety_identifier: str | None) -> DecisionsRequestBody:
+ return _SYSTEMONE_REQUEST_ADAPTER.validate_python({"state": self.state, "questions": self.questions})
+
+
+@dataclass(frozen=True, slots=True)
+class OpenAIDecisionRequestFields:
+ input: OpenAIDecisionInput | None
+ questions: OpenAIDecisionQuestions | None
+
+ def validate(self, safety_identifier: str | None) -> OpenAIDecisionRequestBody:
+ return _OPENAI_REQUEST_ADAPTER.validate_python(
+ {"input": self.input, "questions": self.questions, "safety_identifier": safety_identifier}
+ )
+
+
+RequestFields: TypeAlias = SystemOneRequestFields | OpenAIDecisionRequestFields
+
+
+@dataclass(frozen=True, slots=True, repr=False)
+class DecisionsCall:
+ model: str
+ requested_model: str
+ custom_llm_provider: str
+ provider_config: BaseDecisionsConfig
+ request: DecisionsRequestFormat
+ ir_request: DecisionsIRRequest
+ body: Mapping[str, object] = field(repr=False)
+ api_base: str
+ api_key: str | None = field(repr=False)
+ logging_obj: LiteLLMLoggingObj | None
+ headers: Mapping[str, str]
+ timeout: float | httpx.Timeout | None
+ litellm_params: Mapping[str, object] = field(repr=False)
+
+
+def _supported_providers() -> tuple[str, ...]:
+ return tuple(
+ provider.value
+ for provider in LlmProviders
+ if ProviderConfigManager.get_provider_decisions_config(model="", provider=provider) is not None
+ )
+
+
+def _provider_config(model: str, custom_llm_provider: str) -> BaseDecisionsConfig:
+ provider: Final = next((member for member in LlmProviders if member.value == custom_llm_provider), None)
+ provider_config: Final = (
+ None if provider is None else ProviderConfigManager.get_provider_decisions_config(model, provider)
+ )
+ if provider_config is None:
+ supported: Final = ", ".join(_supported_providers())
+ raise litellm.BadRequestError(
+ message=f"Unknown Decisions provider '{custom_llm_provider}'. Supported providers: {supported}",
+ model=model,
+ llm_provider=custom_llm_provider,
+ )
+ return provider_config
+
+
+def _ir_request(request: DecisionsRequestFormat, safety_identifier: str | None) -> DecisionsIRRequest:
+ match request:
+ case DecisionsRequestBody():
+ return replace(systemone_request_to_ir(request), safety_identifier=safety_identifier)
+ case OpenAIDecisionRequestBody():
+ return openai_request_to_ir(request)
+ case _:
+ assert_never(request)
+
+
+def _drops_params(kwargs: Mapping[str, object]) -> bool:
+ return litellm.drop_params is True or normalize_drop_params(kwargs.get("drop_params")) is True
+
+
+def _request_safety_identifier(safety_identifier: object, kwargs: Mapping[str, object]) -> str | None:
+ if isinstance(safety_identifier, str) or not _drops_params(kwargs):
+ return _SAFETY_IDENTIFIER_ADAPTER.validate_python(safety_identifier)
+ return None
+
+
+@dataclass(frozen=True, slots=True)
+class _UnsupportedSafetyIdentifier:
+ pass
+
+
+def _provider_ir_request(
+ request: DecisionsRequestFormat,
+ *,
+ safety_identifier: str | None,
+ provider_config: BaseDecisionsConfig,
+ kwargs: Mapping[str, object],
+) -> DecisionsIRRequest | _UnsupportedSafetyIdentifier:
+ ir_request: Final = _ir_request(request, safety_identifier)
+ if ir_request.safety_identifier is None or provider_config.supports_safety_identifier:
+ return ir_request
+ if _drops_params(kwargs):
+ return replace(ir_request, safety_identifier=None)
+ return _UnsupportedSafetyIdentifier()
+
+
+def prepare_call(
+ *,
+ model: str,
+ fields: RequestFields,
+ safety_identifier: str | None,
+ api_key: str | None,
+ api_base: str | None,
+ timeout: float | httpx.Timeout | None,
+ custom_llm_provider: str | None,
+ extra_headers: Mapping[str, str] | None,
+ kwargs: Mapping[str, object],
+) -> DecisionsCall:
+ upstream_model, provider, dynamic_api_key, dynamic_api_base = litellm.get_llm_provider(
+ model=model,
+ custom_llm_provider=custom_llm_provider,
+ api_base=api_base,
+ api_key=api_key,
+ )
+ provider_config: Final = _provider_config(upstream_model, provider)
+ if not upstream_model:
+ raise litellm.BadRequestError(
+ message="A model name is required for the Decisions API",
+ model=model,
+ llm_provider=provider,
+ )
+ try:
+ canonical_model: Final = provider_config.canonical_model(upstream_model)
+ except ValueError as error:
+ raise litellm.BadRequestError(message=str(error), model=model, llm_provider=provider) from error
+ try:
+ request_safety_identifier: Final = _request_safety_identifier(safety_identifier, kwargs)
+ request: Final = fields.validate(request_safety_identifier)
+ except ValidationError as error:
+ raise litellm.BadRequestError(
+ message=f"Invalid Decisions request: {error}",
+ model=model,
+ llm_provider=provider,
+ ) from error
+
+ resolved_api_base: Final = provider_config.resolve_api_base(dynamic_api_base or api_base)
+ if resolved_api_base is None:
+ raise litellm.BadRequestError(
+ message=provider_config.missing_api_base_message(provider),
+ model=model,
+ llm_provider=provider,
+ )
+ resolved_api_key: Final = provider_config.resolve_api_key(dynamic_api_key or api_key)
+ if resolved_api_key is None and provider_config.api_key_required:
+ raise litellm.AuthenticationError(
+ message=f"Missing API key for Decisions provider '{provider}'",
+ model=model,
+ llm_provider=provider,
+ )
+
+ ir_request: Final = _provider_ir_request(
+ request,
+ safety_identifier=request_safety_identifier,
+ provider_config=provider_config,
+ kwargs=kwargs,
+ )
+ if isinstance(ir_request, _UnsupportedSafetyIdentifier):
+ raise litellm.UnsupportedParamsError(
+ message=(
+ f"{provider} does not support parameters: ['safety_identifier'], for model={model}. "
+ "To drop these, set `litellm.drop_params=True` or for proxy:\n\n"
+ "`litellm_settings:\n drop_params: true`\n"
+ ),
+ model=model,
+ llm_provider=provider,
+ )
+ body: Final = provider_config.transform_decisions_request(
+ model=canonical_model, request=ir_request, custom_llm_provider=provider
+ )
+ if isinstance(body, UnsupportedDecisionsRequest):
+ raise litellm.BadRequestError(
+ message=f"Decisions provider '{provider}' cannot serve this request: {body.reason}",
+ model=model,
+ llm_provider=provider,
+ )
+
+ logging_obj: Final = kwargs.get("litellm_logging_obj")
+ if isinstance(logging_obj, LiteLLMLoggingObj):
+ logging_obj.update_from_kwargs(
+ kwargs=dict(kwargs),
+ model=canonical_model,
+ litellm_params={
+ "litellm_call_id": kwargs.get("litellm_call_id"),
+ "api_base": provider_config.get_complete_url(resolved_api_base, canonical_model),
+ },
+ custom_llm_provider=provider,
+ )
+ return DecisionsCall(
+ model=canonical_model,
+ requested_model=model,
+ custom_llm_provider=provider,
+ provider_config=provider_config,
+ request=request,
+ ir_request=ir_request,
+ body=body,
+ api_base=resolved_api_base,
+ api_key=resolved_api_key,
+ logging_obj=logging_obj if isinstance(logging_obj, LiteLLMLoggingObj) else None,
+ headers=extra_headers or {},
+ timeout=timeout,
+ litellm_params=kwargs,
+ )
+
+
+def _format_response(response: DecisionsIRResponse, call: DecisionsCall) -> DecisionsResponse | OpenAIDecisionResponse:
+ formatted: Final = _formatted_response(response, call)
+ provider_cost: Final = call.provider_config.provider_reported_cost(response)
+ formatted.set_hidden_params(
+ {
+ "model": f"{call.custom_llm_provider}/{call.model}",
+ "custom_llm_provider": call.custom_llm_provider,
+ "provider_response_model": f"{call.custom_llm_provider}/{call.model}",
+ **({"additional_headers": {RESPONSE_COST_HEADER: provider_cost}} if provider_cost is not None else {}),
+ }
+ )
+ return formatted
+
+
+def _formatted_response(
+ response: DecisionsIRResponse, call: DecisionsCall
+) -> DecisionsResponse | OpenAIDecisionResponse:
+ match call.request:
+ case DecisionsRequestBody():
+ return ir_to_systemone_response(response, call.ir_request)
+ case OpenAIDecisionRequestBody():
+ return ir_to_openai_response(response, call.ir_request, call.requested_model)
+ case _:
+ assert_never(call.request)
+
+
+def _map_upstream_exception(error: Exception, call: DecisionsCall) -> Exception:
+ if isinstance(error, BaseLLMException) and error.status_code_is_synthesized:
+ provider_label: Final = f"{call.custom_llm_provider[0].upper()}{call.custom_llm_provider[1:]}Exception"
+ return litellm.APIConnectionError(
+ message=f"{provider_label} - {error.message}",
+ llm_provider=call.custom_llm_provider,
+ model=f"{call.custom_llm_provider}/{call.model}",
+ )
+ return litellm.exception_type(
+ model=f"{call.custom_llm_provider}/{call.model}",
+ custom_llm_provider=call.custom_llm_provider,
+ original_exception=error,
+ )
+
+
+async def asend(call: DecisionsCall) -> DecisionsResponse | OpenAIDecisionResponse:
+ try:
+ response: Final = await _HANDLER.adecisions(
+ model=call.model,
+ custom_llm_provider=call.custom_llm_provider,
+ logging_obj=call.logging_obj,
+ provider_config=call.provider_config,
+ request=call.ir_request,
+ body=call.body,
+ api_base=call.api_base,
+ api_key=call.api_key,
+ headers=call.headers,
+ timeout=call.timeout,
+ litellm_params=call.litellm_params,
+ )
+ except Exception as error:
+ raise _map_upstream_exception(error, call) from error
+ return _format_response(response, call)
+
+
+def send(call: DecisionsCall) -> DecisionsResponse | OpenAIDecisionResponse:
+ try:
+ response: Final = _HANDLER.decisions(
+ model=call.model,
+ custom_llm_provider=call.custom_llm_provider,
+ logging_obj=call.logging_obj,
+ provider_config=call.provider_config,
+ request=call.ir_request,
+ body=call.body,
+ api_base=call.api_base,
+ api_key=call.api_key,
+ headers=call.headers,
+ timeout=call.timeout,
+ litellm_params=call.litellm_params,
+ )
+ except Exception as error:
+ raise _map_upstream_exception(error, call) from error
+ return _format_response(response, call)
+
+
+def reject_other_format(*, model: str, kwargs: Mapping[str, object], field_name: str, other_function: str) -> None:
+ if field_name not in kwargs:
+ return
+ raise litellm.BadRequestError(
+ message=f"Requests with '{field_name}' go through litellm.{other_function}",
+ model=model,
+ llm_provider="",
+ )
diff --git a/litellm/decisions/main.py b/litellm/decisions/main.py
index f6abb1b2f3a..8b13d04770a 100644
--- a/litellm/decisions/main.py
+++ b/litellm/decisions/main.py
@@ -1,151 +1,56 @@
-from collections.abc import Mapping, Sequence
-from dataclasses import dataclass, field, replace
-from typing import Final, TypeAlias
+import warnings
+from collections.abc import Mapping
+from typing import Final
import httpx
-from pydantic import ConfigDict, TypeAdapter, ValidationError
-from typing_extensions import assert_never
-
-import litellm
-from litellm.litellm_core_utils.core_helpers import RESPONSE_COST_HEADER, normalize_drop_params
-from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
-from litellm.llms.base_llm.chat.transformation import BaseLLMException
-from litellm.llms.base_llm.decisions.transformation import (
- BaseDecisionsConfig,
- ir_to_systemone_response,
- systemone_request_to_ir,
-)
-from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
-from litellm.llms.openai.decisions.transformation import ir_to_openai_response, openai_request_to_ir
-from litellm.types.decisions import (
- DecisionQuestion,
- DecisionsIRRequest,
- DecisionsIRResponse,
- DecisionsJSON,
- DecisionsRequestBody,
- DecisionsResponse,
- OpenAIDecisionInput,
- OpenAIDecisionQuestion,
- OpenAIDecisionRequestBody,
- OpenAIDecisionResponse,
- UnsupportedDecisionsRequest,
+from pydantic import TypeAdapter
+
+from litellm.decisions.call import (
+ DecisionsCall,
+ OpenAIDecisionQuestions,
+ OpenAIDecisionRequestFields,
+ RequestFields,
+ SystemOneQuestions,
+ SystemOneRequestFields,
+ asend,
+ prepare_call,
+ send,
)
-from litellm.types.utils import LlmProviders
-from litellm.utils import ProviderConfigManager, client
+from litellm.types.decisions import DecisionsJSON, DecisionsResponse, OpenAIDecisionInput, OpenAIDecisionResponse
+from litellm.utils import client
-DecisionsQuestions: TypeAlias = (
- Mapping[str, DecisionQuestion | Mapping[str, object]] | Sequence[OpenAIDecisionQuestion | Mapping[str, object]]
+_STATE_ADAPTER: Final[TypeAdapter[DecisionsJSON | None]] = TypeAdapter(DecisionsJSON | None)
+_SYSTEMONE_QUESTIONS_ADAPTER: Final[TypeAdapter[SystemOneQuestions | None]] = TypeAdapter(SystemOneQuestions | None)
+_OPENAI_QUESTIONS_ADAPTER: Final[TypeAdapter[OpenAIDecisionQuestions | None]] = TypeAdapter(
+ OpenAIDecisionQuestions | None
)
-DecisionsRequestFormat: TypeAlias = DecisionsRequestBody | OpenAIDecisionRequestBody
-
-_SYSTEMONE_REQUEST_ADAPTER: Final[TypeAdapter[DecisionsRequestBody]] = TypeAdapter(DecisionsRequestBody)
-_OPENAI_REQUEST_ADAPTER: Final[TypeAdapter[OpenAIDecisionRequestBody]] = TypeAdapter(OpenAIDecisionRequestBody)
-_SAFETY_IDENTIFIER_ADAPTER: Final[TypeAdapter[str | None]] = TypeAdapter(
- str | None, config=ConfigDict(title="safety_identifier")
-)
-_HANDLER: Final = BaseLLMHTTPHandler()
-
-@dataclass(frozen=True, slots=True, repr=False)
-class _DecisionsCall:
- model: str
- requested_model: str
- custom_llm_provider: str
- provider_config: BaseDecisionsConfig
- request: DecisionsRequestFormat
- ir_request: DecisionsIRRequest
- body: Mapping[str, object] = field(repr=False)
- api_base: str
- api_key: str | None = field(repr=False)
- logging_obj: LiteLLMLoggingObj | None
- headers: Mapping[str, str]
- timeout: float | httpx.Timeout | None
- litellm_params: Mapping[str, object] = field(repr=False)
-
-def _supported_providers() -> tuple[str, ...]:
- return tuple(
- provider.value
- for provider in LlmProviders
- if ProviderConfigManager.get_provider_decisions_config(model="", provider=provider) is not None
- )
-
-
-def _provider_config(model: str, custom_llm_provider: str) -> BaseDecisionsConfig:
- provider: Final = next((member for member in LlmProviders if member.value == custom_llm_provider), None)
- provider_config: Final = (
- None if provider is None else ProviderConfigManager.get_provider_decisions_config(model, provider)
- )
- if provider_config is None:
- supported: Final = ", ".join(_supported_providers())
- raise litellm.BadRequestError(
- message=f"Unknown Decisions provider '{custom_llm_provider}'. Supported providers: {supported}",
- model=model,
- llm_provider=custom_llm_provider,
- )
- return provider_config
-
-
-def _validate_request(
- *,
- state: DecisionsJSON | None,
- questions: DecisionsQuestions | None,
+def _request_fields(
decision_input: OpenAIDecisionInput | None,
- safety_identifier: str | None,
-) -> DecisionsRequestFormat:
- if decision_input is None:
- return _SYSTEMONE_REQUEST_ADAPTER.validate_python({"state": state, "questions": questions})
- return _OPENAI_REQUEST_ADAPTER.validate_python(
- {"input": decision_input, "questions": questions, "safety_identifier": safety_identifier}
- )
-
-
-def _ir_request(request: DecisionsRequestFormat, safety_identifier: str | None) -> DecisionsIRRequest:
- match request:
- case DecisionsRequestBody():
- return replace(systemone_request_to_ir(request), safety_identifier=safety_identifier)
- case OpenAIDecisionRequestBody():
- return openai_request_to_ir(request)
- case _:
- assert_never(request)
-
-
-def _drops_params(kwargs: Mapping[str, object]) -> bool:
- return litellm.drop_params is True or normalize_drop_params(kwargs.get("drop_params")) is True
-
-
-def _request_safety_identifier(safety_identifier: object, kwargs: Mapping[str, object]) -> str | None:
- if isinstance(safety_identifier, str) or not _drops_params(kwargs):
- return _SAFETY_IDENTIFIER_ADAPTER.validate_python(safety_identifier)
- return None
-
-
-@dataclass(frozen=True, slots=True)
-class _UnsupportedSafetyIdentifier:
- pass
-
-
-def _provider_ir_request(
- request: DecisionsRequestFormat,
- *,
- safety_identifier: str | None,
- provider_config: BaseDecisionsConfig,
+ questions: OpenAIDecisionQuestions | SystemOneQuestions | None,
kwargs: Mapping[str, object],
-) -> DecisionsIRRequest | _UnsupportedSafetyIdentifier:
- ir_request: Final = _ir_request(request, safety_identifier)
- if ir_request.safety_identifier is None or provider_config.supports_safety_identifier:
- return ir_request
- if _drops_params(kwargs):
- return replace(ir_request, safety_identifier=None)
- return _UnsupportedSafetyIdentifier()
+) -> RequestFields:
+ if "state" not in kwargs:
+ return OpenAIDecisionRequestFields(
+ input=decision_input, questions=_OPENAI_QUESTIONS_ADAPTER.validate_python(questions)
+ )
+ warnings.warn(
+ "litellm.decisions(state=...) is deprecated, call litellm.systemone for the System One request format",
+ UserWarning,
+ stacklevel=5,
+ )
+ return SystemOneRequestFields(
+ state=_STATE_ADAPTER.validate_python(kwargs["state"]),
+ questions=_SYSTEMONE_QUESTIONS_ADAPTER.validate_python(questions),
+ )
-def _prepare_call(
+def _prepare_decisions_call(
*,
model: str,
- state: DecisionsJSON | None,
- questions: DecisionsQuestions | None,
decision_input: OpenAIDecisionInput | None,
+ questions: OpenAIDecisionQuestions | SystemOneQuestions | None,
safety_identifier: str | None,
api_key: str | None,
api_base: str | None,
@@ -153,174 +58,37 @@ def _prepare_call(
custom_llm_provider: str | None,
extra_headers: Mapping[str, str] | None,
kwargs: Mapping[str, object],
-) -> _DecisionsCall:
- upstream_model, provider, dynamic_api_key, dynamic_api_base = litellm.get_llm_provider(
+) -> DecisionsCall:
+ return prepare_call(
model=model,
- custom_llm_provider=custom_llm_provider,
- api_base=api_base,
+ fields=_request_fields(decision_input, questions, kwargs),
+ safety_identifier=safety_identifier,
api_key=api_key,
- )
- provider_config: Final = _provider_config(upstream_model, provider)
- if not upstream_model:
- raise litellm.BadRequestError(
- message="A model name is required for the Decisions API",
- model=model,
- llm_provider=provider,
- )
- if state is not None and decision_input is not None:
- raise litellm.BadRequestError(
- message="Pass either state (System One format) or input (OpenAI format) to the Decisions API, not both",
- model=model,
- llm_provider=provider,
- )
- try:
- canonical_model: Final = provider_config.canonical_model(upstream_model)
- except ValueError as error:
- raise litellm.BadRequestError(message=str(error), model=model, llm_provider=provider) from error
- try:
- request_safety_identifier: Final = _request_safety_identifier(safety_identifier, kwargs)
- request: Final = _validate_request(
- state=state,
- questions=questions,
- decision_input=decision_input,
- safety_identifier=request_safety_identifier,
- )
- except ValidationError as error:
- raise litellm.BadRequestError(
- message=f"Invalid Decisions request: {error}",
- model=model,
- llm_provider=provider,
- ) from error
-
- resolved_api_base: Final = provider_config.resolve_api_base(dynamic_api_base or api_base)
- if resolved_api_base is None:
- raise litellm.BadRequestError(
- message=provider_config.missing_api_base_message(provider),
- model=model,
- llm_provider=provider,
- )
- resolved_api_key: Final = provider_config.resolve_api_key(dynamic_api_key or api_key)
- if resolved_api_key is None and provider_config.api_key_required:
- raise litellm.AuthenticationError(
- message=f"Missing API key for Decisions provider '{provider}'",
- model=model,
- llm_provider=provider,
- )
-
- ir_request: Final = _provider_ir_request(
- request,
- safety_identifier=request_safety_identifier,
- provider_config=provider_config,
- kwargs=kwargs,
- )
- if isinstance(ir_request, _UnsupportedSafetyIdentifier):
- raise litellm.UnsupportedParamsError(
- message=(
- f"{provider} does not support parameters: ['safety_identifier'], for model={model}. "
- "To drop these, set `litellm.drop_params=True` or for proxy:\n\n"
- "`litellm_settings:\n drop_params: true`\n"
- ),
- model=model,
- llm_provider=provider,
- )
- body: Final = provider_config.transform_decisions_request(
- model=canonical_model, request=ir_request, custom_llm_provider=provider
- )
- if isinstance(body, UnsupportedDecisionsRequest):
- raise litellm.BadRequestError(
- message=f"Decisions provider '{provider}' cannot serve this request: {body.reason}",
- model=model,
- llm_provider=provider,
- )
-
- logging_obj: Final = kwargs.get("litellm_logging_obj")
- if isinstance(logging_obj, LiteLLMLoggingObj):
- logging_obj.update_from_kwargs(
- kwargs=dict(kwargs),
- model=canonical_model,
- litellm_params={
- "litellm_call_id": kwargs.get("litellm_call_id"),
- "api_base": provider_config.get_complete_url(resolved_api_base, canonical_model),
- },
- custom_llm_provider=provider,
- )
- return _DecisionsCall(
- model=canonical_model,
- requested_model=model,
- custom_llm_provider=provider,
- provider_config=provider_config,
- request=request,
- ir_request=ir_request,
- body=body,
- api_base=resolved_api_base,
- api_key=resolved_api_key,
- logging_obj=logging_obj if isinstance(logging_obj, LiteLLMLoggingObj) else None,
- headers=extra_headers or {},
+ api_base=api_base,
timeout=timeout,
- litellm_params=kwargs,
- )
-
-
-def _format_response(response: DecisionsIRResponse, call: _DecisionsCall) -> DecisionsResponse | OpenAIDecisionResponse:
- formatted: Final = _formatted_response(response, call)
- provider_cost: Final = call.provider_config.provider_reported_cost(response)
- formatted.set_hidden_params(
- {
- "model": f"{call.custom_llm_provider}/{call.model}",
- "custom_llm_provider": call.custom_llm_provider,
- "provider_response_model": f"{call.custom_llm_provider}/{call.model}",
- **({"additional_headers": {RESPONSE_COST_HEADER: provider_cost}} if provider_cost is not None else {}),
- }
- )
- return formatted
-
-
-def _formatted_response(
- response: DecisionsIRResponse, call: _DecisionsCall
-) -> DecisionsResponse | OpenAIDecisionResponse:
- match call.request:
- case DecisionsRequestBody():
- return ir_to_systemone_response(response, call.ir_request)
- case OpenAIDecisionRequestBody():
- return ir_to_openai_response(response, call.ir_request, call.requested_model)
- case _:
- assert_never(call.request)
-
-
-def _map_upstream_exception(error: Exception, call: _DecisionsCall) -> Exception:
- if isinstance(error, BaseLLMException) and error.status_code_is_synthesized:
- provider_label: Final = f"{call.custom_llm_provider[0].upper()}{call.custom_llm_provider[1:]}Exception"
- return litellm.APIConnectionError(
- message=f"{provider_label} - {error.message}",
- llm_provider=call.custom_llm_provider,
- model=f"{call.custom_llm_provider}/{call.model}",
- )
- return litellm.exception_type(
- model=f"{call.custom_llm_provider}/{call.model}",
- custom_llm_provider=call.custom_llm_provider,
- original_exception=error,
+ custom_llm_provider=custom_llm_provider,
+ extra_headers=extra_headers,
+ kwargs={key: value for key, value in kwargs.items() if key != "state"},
)
@client
async def adecisions(
model: str,
- state: DecisionsJSON | None = None,
- questions: DecisionsQuestions | None = None,
+ input: OpenAIDecisionInput | None = None,
+ questions: OpenAIDecisionQuestions | SystemOneQuestions | None = None,
+ safety_identifier: str | None = None,
api_key: str | None = None,
api_base: str | None = None,
timeout: float | httpx.Timeout | None = None,
custom_llm_provider: str | None = None,
extra_headers: Mapping[str, str] | None = None,
- input: OpenAIDecisionInput | None = None,
- safety_identifier: str | None = None,
**kwargs: object,
-) -> DecisionsResponse | OpenAIDecisionResponse:
- call: Final = _prepare_call(
+) -> OpenAIDecisionResponse | DecisionsResponse:
+ call: Final = _prepare_decisions_call(
model=model,
- state=state,
- questions=questions,
decision_input=input,
+ questions=questions,
safety_identifier=safety_identifier,
api_key=api_key,
api_base=api_base,
@@ -329,44 +97,26 @@ async def adecisions(
extra_headers=extra_headers,
kwargs=kwargs,
)
- try:
- response: Final = await _HANDLER.adecisions(
- model=call.model,
- custom_llm_provider=call.custom_llm_provider,
- logging_obj=call.logging_obj,
- provider_config=call.provider_config,
- request=call.ir_request,
- body=call.body,
- api_base=call.api_base,
- api_key=call.api_key,
- headers=call.headers,
- timeout=call.timeout,
- litellm_params=call.litellm_params,
- )
- except Exception as error:
- raise _map_upstream_exception(error, call) from error
- return _format_response(response, call)
+ return await asend(call)
@client
def decisions(
model: str,
- state: DecisionsJSON | None = None,
- questions: DecisionsQuestions | None = None,
+ input: OpenAIDecisionInput | None = None,
+ questions: OpenAIDecisionQuestions | SystemOneQuestions | None = None,
+ safety_identifier: str | None = None,
api_key: str | None = None,
api_base: str | None = None,
timeout: float | httpx.Timeout | None = None,
custom_llm_provider: str | None = None,
extra_headers: Mapping[str, str] | None = None,
- input: OpenAIDecisionInput | None = None,
- safety_identifier: str | None = None,
**kwargs: object,
-) -> DecisionsResponse | OpenAIDecisionResponse:
- call: Final = _prepare_call(
+) -> OpenAIDecisionResponse | DecisionsResponse:
+ call: Final = _prepare_decisions_call(
model=model,
- state=state,
- questions=questions,
decision_input=input,
+ questions=questions,
safety_identifier=safety_identifier,
api_key=api_key,
api_base=api_base,
@@ -375,23 +125,7 @@ def decisions(
extra_headers=extra_headers,
kwargs=kwargs,
)
- try:
- response: Final = _HANDLER.decisions(
- model=call.model,
- custom_llm_provider=call.custom_llm_provider,
- logging_obj=call.logging_obj,
- provider_config=call.provider_config,
- request=call.ir_request,
- body=call.body,
- api_base=call.api_base,
- api_key=call.api_key,
- headers=call.headers,
- timeout=call.timeout,
- litellm_params=call.litellm_params,
- )
- except Exception as error:
- raise _map_upstream_exception(error, call) from error
- return _format_response(response, call)
+ return send(call)
__all__ = ["adecisions", "decisions"]
diff --git a/litellm/litellm_core_utils/health_check_helpers.py b/litellm/litellm_core_utils/health_check_helpers.py
index a035f86ea56..3cbc2d770cc 100644
--- a/litellm/litellm_core_utils/health_check_helpers.py
+++ b/litellm/litellm_core_utils/health_check_helpers.py
@@ -311,7 +311,7 @@ class HealthCheckHelpers:
**_filter_model_params(model_params=model_params),
document=_ocr_health_check_document(model=model, custom_llm_provider=custom_llm_provider),
),
- "evaluation": lambda: litellm.adecisions(
+ "evaluation": lambda: litellm.asystemone(
**DECISIONS_CALL_PARAMS.validate_python(
{
"state": prompt or "health check",
diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py
index ed9ac258e16..6b87960fcc0 100644
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@ -184,6 +184,7 @@ ProxyRouteType: TypeAlias = Literal[
"aocr",
"asearch",
"adecisions",
+ "asystemone",
"avideo_generation",
"avideo_list",
"avideo_status",
@@ -2074,6 +2075,7 @@ class ProxyBaseLLMRequestProcessing:
"aocr",
"asearch",
"adecisions",
+ "asystemone",
"avideo_generation",
"avideo_list",
"avideo_status",
diff --git a/litellm/proxy/decisions_endpoints/endpoints.py b/litellm/proxy/decisions_endpoints/endpoints.py
index c8d4768dad0..dbb7b69bd8b 100644
--- a/litellm/proxy/decisions_endpoints/endpoints.py
+++ b/litellm/proxy/decisions_endpoints/endpoints.py
@@ -1,6 +1,6 @@
from collections.abc import Mapping
from types import MappingProxyType
-from typing import Annotated, Final
+from typing import Annotated, Final, Literal
from fastapi import APIRouter, Depends, Request, Response
from fastapi.responses import ORJSONResponse # pyright: ignore[reportDeprecated] # required endpoint contract
@@ -109,6 +109,7 @@ async def _process_decisions(
fastapi_response: Response,
user_api_key_dict: UserAPIKeyAuth,
body_adapter: TypeAdapter[DecisionsRequestBody] | TypeAdapter[OpenAIDecisionRequestBody],
+ route_type: Literal["adecisions", "asystemone"],
) -> object:
from litellm.proxy.proxy_server import (
general_settings as proxy_general_settings,
@@ -146,7 +147,7 @@ async def _process_decisions(
request=request,
fastapi_response=fastapi_response,
user_api_key_dict=user_api_key_dict,
- route_type="adecisions",
+ route_type=route_type,
proxy_logging_obj=proxy_logging_obj,
llm_router=llm_router,
general_settings=general_settings,
@@ -208,6 +209,7 @@ async def systemone(
fastapi_response=fastapi_response,
user_api_key_dict=user_api_key_dict,
body_adapter=_DECISIONS_REQUEST_BODY_ADAPTER,
+ route_type="asystemone",
)
@@ -250,4 +252,5 @@ async def decisions(
fastapi_response=fastapi_response,
user_api_key_dict=user_api_key_dict,
body_adapter=_OPENAI_DECISION_REQUEST_BODY_ADAPTER,
+ route_type="adecisions",
)
diff --git a/litellm/proxy/route_llm_request.py b/litellm/proxy/route_llm_request.py
index 2a9312dc0e3..d8b8a68c8f9 100644
--- a/litellm/proxy/route_llm_request.py
+++ b/litellm/proxy/route_llm_request.py
@@ -94,6 +94,7 @@ ROUTE_ENDPOINT_MAPPING: Final = {
"aocr": "/ocr",
"asearch": "/search",
"adecisions": "/decisions",
+ "asystemone": "/systemone",
"avideo_generation": "/videos",
"avideo_list": "/videos",
"avideo_status": "/videos/{video_id}",
@@ -519,6 +520,7 @@ RouteType = Literal[
"aocr",
"asearch",
"adecisions",
+ "asystemone",
"avideo_generation",
"avideo_list",
"avideo_status",
diff --git a/litellm/router.py b/litellm/router.py
index f173cdb37b4..fd16c289b0d 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -2233,6 +2233,11 @@ class Router:
self.adecisions = self.factory_function(adecisions, call_type="adecisions")
self.decisions = self.factory_function(decisions, call_type="decisions")
+ from litellm.systemone import asystemone, systemone
+
+ self.asystemone = self.factory_function(asystemone, call_type="asystemone") # pyright: ignore[reportUnknownMemberType] # factory_function takes a bare Callable
+ self.systemone = self.factory_function(systemone, call_type="systemone") # pyright: ignore[reportUnknownMemberType] # factory_function takes a bare Callable
+
def _initialize_video_endpoints(self):
"""Initialize video endpoints."""
from litellm.videos import (
@@ -6996,6 +7001,8 @@ class Router:
"search",
"adecisions",
"decisions",
+ "asystemone",
+ "systemone",
"aadapter_generate_content",
"avideo_generation",
"video_generation",
@@ -7070,6 +7077,7 @@ class Router:
"ocr",
"search",
"decisions",
+ "systemone",
"video_generation",
"video_list",
"video_status",
@@ -7238,6 +7246,7 @@ class Router:
"aocr",
"ocr",
"adecisions",
+ "asystemone",
"avideo_generation",
"avideo_list",
"avideo_status",
diff --git a/litellm/systemone/__init__.py b/litellm/systemone/__init__.py
new file mode 100644
index 00000000000..eb4971a16e4
--- /dev/null
+++ b/litellm/systemone/__init__.py
@@ -0,0 +1,3 @@
+from litellm.systemone.main import asystemone, systemone
+
+__all__ = ["asystemone", "systemone"]
diff --git a/litellm/systemone/main.py b/litellm/systemone/main.py
new file mode 100644
index 00000000000..754b69142f9
--- /dev/null
+++ b/litellm/systemone/main.py
@@ -0,0 +1,107 @@
+from collections.abc import Mapping
+from typing import Final
+
+import httpx
+
+from litellm.decisions.call import (
+ DecisionsCall,
+ SystemOneQuestions,
+ SystemOneRequestFields,
+ asend,
+ prepare_call,
+ reject_other_format,
+ send,
+)
+from litellm.types.decisions import DecisionsJSON, DecisionsResponse
+from litellm.utils import client # pyright: ignore[reportUnknownVariableType] # client is an untyped decorator
+
+
+def _prepare_systemone_call(
+ *,
+ model: str,
+ state: DecisionsJSON | None,
+ questions: SystemOneQuestions | None,
+ safety_identifier: str | None,
+ api_key: str | None,
+ api_base: str | None,
+ timeout: float | httpx.Timeout | None,
+ custom_llm_provider: str | None,
+ extra_headers: Mapping[str, str] | None,
+ kwargs: Mapping[str, object],
+) -> DecisionsCall:
+ reject_other_format(model=model, kwargs=kwargs, field_name="input", other_function="decisions")
+ return prepare_call(
+ model=model,
+ fields=SystemOneRequestFields(state=state, questions=questions),
+ safety_identifier=safety_identifier,
+ api_key=api_key,
+ api_base=api_base,
+ timeout=timeout,
+ custom_llm_provider=custom_llm_provider,
+ extra_headers=extra_headers,
+ kwargs=kwargs,
+ )
+
+
+def _systemone_response(response: object) -> DecisionsResponse:
+ assert isinstance(response, DecisionsResponse)
+ return response
+
+
+@client
+async def asystemone(
+ model: str,
+ state: DecisionsJSON | None = None,
+ questions: SystemOneQuestions | None = None,
+ api_key: str | None = None,
+ api_base: str | None = None,
+ timeout: float | httpx.Timeout | None = None,
+ custom_llm_provider: str | None = None,
+ extra_headers: Mapping[str, str] | None = None,
+ safety_identifier: str | None = None,
+ **kwargs: object, # kwargs-ok: litellm_params forwarded by @client
+) -> DecisionsResponse:
+ call: Final = _prepare_systemone_call(
+ model=model,
+ state=state,
+ questions=questions,
+ safety_identifier=safety_identifier,
+ api_key=api_key,
+ api_base=api_base,
+ timeout=timeout,
+ custom_llm_provider=custom_llm_provider,
+ extra_headers=extra_headers,
+ kwargs=kwargs,
+ )
+ return _systemone_response(await asend(call))
+
+
+@client
+def systemone(
+ model: str,
+ state: DecisionsJSON | None = None,
+ questions: SystemOneQuestions | None = None,
+ api_key: str | None = None,
+ api_base: str | None = None,
+ timeout: float | httpx.Timeout | None = None,
+ custom_llm_provider: str | None = None,
+ extra_headers: Mapping[str, str] | None = None,
+ safety_identifier: str | None = None,
+ **kwargs: object, # kwargs-ok: litellm_params forwarded by @client
+) -> DecisionsResponse:
+ call: Final = _prepare_systemone_call(
+ model=model,
+ state=state,
+ questions=questions,
+ safety_identifier=safety_identifier,
+ api_key=api_key,
+ api_base=api_base,
+ timeout=timeout,
+ custom_llm_provider=custom_llm_provider,
+ extra_headers=extra_headers,
+ kwargs=kwargs,
+ )
+ return _systemone_response(send(call))
+
+
+__all__ = ["asystemone", "systemone"]
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index 13fd86b74a7..6f89ac614e8 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -489,6 +489,8 @@ class CallTypes(str, Enum):
asearch = "asearch"
decisions = "decisions"
adecisions = "adecisions"
+ systemone = "systemone"
+ asystemone = "asystemone"
arealtime = "_arealtime"
aresponses_websocket = "_aresponses_websocket"
create_batch = "create_batch"
@@ -677,6 +679,8 @@ CallTypesLiteral = Literal[
"asearch",
"decisions",
"adecisions",
+ "systemone",
+ "asystemone",
"_arealtime",
"_aresponses_websocket",
"create_batch",
@@ -788,8 +792,8 @@ API_ROUTE_TO_CALL_TYPES: Final[Mapping[str, Sequence[CallTypes]]] = {
"/v1/search": [CallTypes.asearch, CallTypes.search],
"/decisions": [CallTypes.adecisions, CallTypes.decisions],
"/v1/decisions": [CallTypes.adecisions, CallTypes.decisions],
- "/systemone": [CallTypes.adecisions, CallTypes.decisions],
- "/v1/systemone": [CallTypes.adecisions, CallTypes.decisions],
+ "/systemone": [CallTypes.asystemone, CallTypes.systemone],
+ "/v1/systemone": [CallTypes.asystemone, CallTypes.systemone],
# Batches
"/batches": [CallTypes.acreate_batch, CallTypes.create_batch],
"/v1/batches": [CallTypes.acreate_batch, CallTypes.create_batch],
diff --git a/litellm/utils.py b/litellm/utils.py
index 6774771dbf9..44dc75f45d7 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -974,6 +974,12 @@ def _ocr_document_summary(document: object) -> str:
# Runs once per call to check if the user wants to send their data anywhere - PostHog/Sentry/Slack/etc.
+
+_DECISION_CALL_TYPES: Final[frozenset[str]] = frozenset(
+ (CallTypes.decisions.value, CallTypes.adecisions.value, CallTypes.systemone.value, CallTypes.asystemone.value)
+)
+
+
def function_setup(
original_function: str,
rules_obj: Rules,
@@ -1220,7 +1226,7 @@ def function_setup(
if isinstance(search_query, list)
else search_query
)
- elif call_type in (CallTypes.decisions.value, CallTypes.adecisions.value):
+ elif call_type in _DECISION_CALL_TYPES:
decisions_state: Final = args[1] if len(args) > 1 else kwargs.get("state") or kwargs.get("input") or ""
messages = decisions_state if isinstance(decisions_state, str) else json.dumps(decisions_state, default=str)
elif call_type in (CallTypes.image_edit.value, CallTypes.aimage_edit.value):
diff --git a/tests/integration/providers/test_databricks_decisions_wire.py b/tests/integration/providers/test_databricks_decisions_wire.py
index 93dc2ea04fa..9b9f54e815d 100644
--- a/tests/integration/providers/test_databricks_decisions_wire.py
+++ b/tests/integration/providers/test_databricks_decisions_wire.py
@@ -179,7 +179,7 @@ def _assert_refused_before_any_upstream_call(gateway: Gateway, model: str, messa
assert message in response.text, response.text
assert _upstream_calls(gateway, handle) == []
row: Final = _spend_row(response.headers["x-litellm-call-id"])
- assert (row["status"], row["call_type"], _number(row["spend"])) == ("failure", "adecisions", 0.0), row
+ assert (row["status"], row["call_type"], _number(row["spend"])) == ("failure", "asystemone", 0.0), row
@pytest.mark.parametrize("name", [name for _, name in _NON_BARE_NAMES], ids=[label for label, _ in _NON_BARE_NAMES])
@@ -251,7 +251,7 @@ def test_an_openai_format_request_at_v1_decisions_reaches_the_serving_endpoint_a
row["model_group"],
row["api_base"],
_number(row["spend"]),
- ) == ("success", "adecisions", "databricks", deployment, f"{handle.api_base()}/{_ENDPOINT}/invocations", 0.0), (
+ ) == ("success", "asystemone", "databricks", deployment, f"{handle.api_base()}/{_ENDPOINT}/invocations", 0.0), (
row
)
@@ -284,7 +284,7 @@ def test_a_wildcard_deployment_sends_each_request_to_the_named_endpoint_and_bill
row["model_group"],
row["api_base"],
_number(row["spend"]),
- ) == ("success", "adecisions", "databricks", model, f"{handle.api_base()}/{_ENDPOINT}/invocations", 0.0), (
+ ) == ("success", "asystemone", "databricks", model, f"{handle.api_base()}/{_ENDPOINT}/invocations", 0.0), (
row
)
@@ -322,7 +322,7 @@ def test_a_five_kilobyte_endpoint_name_reaches_the_upstream_and_its_not_found_an
row: Final = _spend_row(response.headers["x-litellm-call-id"])
assert (row["status"], row["call_type"], row["model_group"], _number(row["spend"])) == (
"failure",
- "adecisions",
+ "asystemone",
f"{prefix}/{name}",
0.0,
), row
@@ -343,7 +343,7 @@ def test_a_databricks_error_keeps_its_status_and_message_and_bills_nothing(
row: Final = _spend_row(response.headers["x-litellm-call-id"])
assert (row["status"], row["call_type"], row["model_group"], _number(row["spend"])) == (
"failure",
- "adecisions",
+ "asystemone",
model,
0.0,
), row
@@ -515,4 +515,4 @@ def test_a_megabyte_endpoint_name_is_refused_in_linear_time_while_liveliness_sta
assert _BARE_NAME_RULE in response.text, response.text[-400:]
assert _upstream_calls(gateway, handle) == []
row: Final = _spend_row(response.headers["x-litellm-call-id"])
- assert (row["status"], row["call_type"], _number(row["spend"])) == ("failure", "adecisions", 0.0), row
+ assert (row["status"], row["call_type"], _number(row["spend"])) == ("failure", "asystemone", 0.0), row
diff --git a/tests/integration/providers/test_decisions_wire.py b/tests/integration/providers/test_decisions_wire.py
index 16c938e3995..2862632d132 100644
--- a/tests/integration/providers/test_decisions_wire.py
+++ b/tests/integration/providers/test_decisions_wire.py
@@ -278,7 +278,7 @@ def test_each_provider_gets_its_own_path_key_and_body_and_is_billed(gateway: Gat
row["api_base"],
row["prompt_tokens"],
row["completion_tokens"],
- ) == ("success", "adecisions", provider.name, model, f"{handle.api_base()}{provider.path}", 367, 3)
+ ) == ("success", "asystemone", provider.name, model, f"{handle.api_base()}{provider.path}", 367, 3)
assert math.isclose(_number(row["spend"]), expected_spend, rel_tol=1e-9), row
@@ -339,7 +339,7 @@ async def test_sdk_sync_and_async_clients_send_the_same_request(gateway: Gateway
synchronous: Final = litellm.decisions(
model=provider.model, state=_STATE, questions=_SDK_QUESTIONS, api_base=handle.api_base(), api_key=_API_KEY
)
- asynchronous: Final = await litellm.adecisions(
+ asynchronous: Final = await litellm.asystemone(
model=provider.model, state=_STATE, questions=_SDK_QUESTIONS, api_base=handle.api_base(), api_key=_API_KEY
)
for response in (synchronous, asynchronous):
@@ -507,7 +507,7 @@ def test_upstream_errors_keep_their_status_and_log_an_unbilled_failure(gateway:
row: Final = _spend_row(response.headers["x-litellm-call-id"])
assert (row["status"], row["call_type"], row["model_group"], _number(row["spend"])) == (
"failure",
- "adecisions",
+ "asystemone",
model,
0.0,
)
@@ -579,7 +579,7 @@ async def test_sdk_openrouter_connection_failures_raise_a_connection_error(gatew
model=_OPENROUTER.model, state=_STATE, questions=_SDK_QUESTIONS, api_base=dead_api_base, api_key=_API_KEY
)
with pytest.raises(litellm.APIConnectionError):
- await litellm.adecisions(
+ await litellm.asystemone(
model=_OPENROUTER.model, state=_STATE, questions=_SDK_QUESTIONS, api_base=dead_api_base, api_key=_API_KEY
)
diff --git a/tests/integration/providers/test_strands_decider_agentcore_wire.py b/tests/integration/providers/test_strands_decider_agentcore_wire.py
index bf5da453137..493d8c238fa 100644
--- a/tests/integration/providers/test_strands_decider_agentcore_wire.py
+++ b/tests/integration/providers/test_strands_decider_agentcore_wire.py
@@ -415,7 +415,7 @@ def test_an_arn_deployment_answers_on_every_decisions_route_signed_for_bedrock_a
row = _spend_row(response.headers["x-litellm-call-id"])
assert row == {
"status": "success",
- "call_type": "adecisions",
+ "call_type": "asystemone",
"custom_llm_provider": "strands_decider",
"model_group": _SIGNED,
"api_base": _invocations_url("audit_signed"),
@@ -694,7 +694,7 @@ async def test_sdk_sync_and_async_calls_reach_the_runtime_signed(
aws_access_key_id=_ACCESS_KEY,
aws_secret_access_key=_SECRET_KEY,
)
- asynchronous: Final = await litellm.adecisions(
+ asynchronous: Final = await litellm.asystemone(
model=_MODEL,
state=_STATE,
questions=_SDK_QUESTIONS,
@@ -703,7 +703,7 @@ async def test_sdk_sync_and_async_calls_reach_the_runtime_signed(
aws_secret_access_key=_SECRET_KEY,
)
monkeypatch.setenv("STRANDS_DECIDER_API_KEY", _ENV_JWT)
- bearer: Final = await litellm.adecisions(
+ bearer: Final = await litellm.asystemone(
model=_MODEL, state=_STATE, questions=_SDK_QUESTIONS, api_base=_arn("audit_sdk_env_key")
)
finally:
diff --git a/tests/unit/decisions/test_main.py b/tests/unit/decisions/test_main.py
index ebe0eedea7f..81f5b60a036 100644
--- a/tests/unit/decisions/test_main.py
+++ b/tests/unit/decisions/test_main.py
@@ -163,7 +163,7 @@ async def test_adecisions_sends_the_provider_wire_contract(
) -> None:
route: Final = respx_mock.post(url).respond(json=_RESPONSE)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model=model,
state={"source": "unit-test"},
questions=_QUESTIONS,
@@ -225,7 +225,7 @@ async def test_router_dispatches_typesafe_decisions_without_api_base(
)
upstream: Final = respx_mock.post("https://api.typesafe.ai/v1/systemone").respond(json=_RESPONSE)
- response: Final = await router.adecisions(
+ response: Final = await router.asystemone(
model="jev",
state="router-test",
questions={
@@ -256,7 +256,7 @@ async def test_router_dispatches_typesafe_decisions_without_api_base(
def test_decisions_uses_the_same_wire_contract_for_sync_calls(respx_mock: respx.MockRouter) -> None:
route: Final = respx_mock.post("https://api.perplexity.ai/v1/decisions").respond(json=_RESPONSE)
- response: Final = litellm.decisions(
+ response: Final = litellm.systemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -276,7 +276,7 @@ def test_openrouter_response_keeps_provider_fields(respx_mock: respx.MockRouter)
}
respx_mock.post("https://openrouter.ai/api/alpha/decisions").respond(json=payload)
- response: Final = litellm.decisions(
+ response: Final = litellm.systemone(
model="openrouter/typesafe/jev-1.13",
state="review",
questions=_QUESTIONS,
@@ -364,7 +364,7 @@ async def test_decisions_cost_is_in_standard_logging_object(respx_mock: respx.Mo
litellm.callbacks = [recording_logger]
try:
- await litellm.adecisions(
+ await litellm.asystemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -389,7 +389,7 @@ async def test_decisions_cost_is_in_standard_logging_object(respx_mock: respx.Mo
@pytest.mark.asyncio
async def test_unknown_provider_is_rejected_before_http(respx_mock: respx.MockRouter) -> None:
with pytest.raises(litellm.BadRequestError, match="LLM Provider NOT provided"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="unknown/jev-1.13",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -402,7 +402,7 @@ async def test_unknown_provider_is_rejected_before_http(respx_mock: respx.MockRo
@pytest.mark.asyncio
async def test_provider_without_decisions_support_is_rejected_before_http(respx_mock: respx.MockRouter) -> None:
with pytest.raises(litellm.BadRequestError, match=r"Unknown Decisions provider 'anthropic'\. Supported providers"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="anthropic/claude-sonnet-4-5",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -416,7 +416,7 @@ async def test_provider_without_decisions_support_is_rejected_before_http(respx_
async def test_empty_custom_provider_falls_back_to_the_model_prefix(respx_mock: respx.MockRouter) -> None:
route: Final = respx_mock.post("https://api.perplexity.ai/v1/decisions").respond(json=_RESPONSE)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -436,7 +436,7 @@ async def test_upstream_reply_without_answers_is_a_server_error(respx_mock: resp
)
with pytest.raises(litellm.InternalServerError, match="unexpected response"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -464,7 +464,7 @@ async def test_router_sends_the_openrouter_deployment_key_when_the_provider_is_a
)
upstream: Final = respx_mock.post("https://egress.example/openrouter/alpha/decisions").respond(json=_RESPONSE)
- await router.adecisions(
+ await router.asystemone(
model="jev",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -478,7 +478,7 @@ async def test_router_sends_the_openrouter_deployment_key_when_the_provider_is_a
@pytest.mark.asyncio
async def test_invalid_question_is_rejected_before_http(respx_mock: respx.MockRouter) -> None:
with pytest.raises(litellm.BadRequestError, match="Invalid Decisions request"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"sentiment": {"type": "choice"}},
@@ -495,7 +495,7 @@ def test_upstream_bad_request_maps_to_litellm_error(respx_mock: respx.MockRouter
)
with pytest.raises(litellm.BadRequestError):
- litellm.decisions(
+ litellm.systemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -509,7 +509,7 @@ def test_unreachable_upstream_maps_to_a_connection_error(respx_mock: respx.MockR
)
with pytest.raises(litellm.APIConnectionError, match="PerplexityException - Cannot connect to host"):
- litellm.decisions(
+ litellm.systemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -525,7 +525,7 @@ def test_server_key_is_sent_to_an_explicit_api_base(
monkeypatch.delenv("PERPLEXITY_API_KEY", raising=False)
route: Final = respx_mock.post("https://egress.example/perplexity/v1/decisions").respond(json=_RESPONSE)
- litellm.decisions(
+ litellm.systemone(
model="perplexity/pplx-decider-v1-27b",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -555,7 +555,7 @@ async def test_cloudflare_clef_resolves_model_and_response_envelope(
"https://api.cloudflare.com/client/v4/accounts/acct/ai/run/@cf/cloudflare/clef"
).respond(json=response_body)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model=model,
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -585,7 +585,7 @@ async def test_cloudflare_clef_flash_uses_flash_endpoint_and_request_model(
"https://api.cloudflare.com/client/v4/accounts/acct/ai/run/@cf/cloudflare/clef-flash"
).respond(json=_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="cloudflare/clef-flash",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -607,7 +607,7 @@ async def test_cloudflare_api_base_from_env_uses_workers_ai_run_path(
"https://api.cloudflare.com/client/v4/accounts/acct/ai/run/@cf/cloudflare/clef"
).respond(json=_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="cloudflare/clef",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -626,7 +626,7 @@ async def test_cloudflare_requires_account_id_or_api_base_before_http(
monkeypatch.setenv("CLOUDFLARE_API_KEY", "cloudflare-key")
with pytest.raises(litellm.BadRequestError, match="Missing CLOUDFLARE_ACCOUNT_ID - set CLOUDFLARE_ACCOUNT_ID"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="cloudflare/clef",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -647,7 +647,7 @@ async def test_cloudflare_clef_cost_uses_the_model_cost_map(
json=_RESPONSE
)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="cloudflare/clef",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -672,7 +672,7 @@ async def test_strands_decider_requires_api_base_before_http(
monkeypatch.delenv("STRANDS_DECIDER_API_KEY", raising=False)
with pytest.raises(litellm.BadRequestError, match="api_base is required"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -690,7 +690,7 @@ async def test_strands_decider_without_key_preserves_response_extras(
monkeypatch.delenv("STRANDS_DECIDER_API_KEY", raising=False)
route: Final = respx_mock.post("https://strands.example/v1/systemone").respond(json=_STRANDS_RESPONSE)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -717,7 +717,7 @@ async def test_strands_decider_plain_api_base_answers_while_every_aws_signing_th
try:
response: Final = await asyncio.wait_for(
- litellm.adecisions(
+ litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -741,7 +741,7 @@ async def test_strands_decider_uses_key_from_matching_environment_base(
monkeypatch.setenv("STRANDS_DECIDER_API_KEY", "strands-key")
route: Final = respx_mock.post("https://strands.example/v1/systemone").respond(json=_STRANDS_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -773,7 +773,7 @@ async def test_strands_decider_provider_resolution_and_router_dispatch(
)
route: Final = respx_mock.post("https://strands.example/v1/systemone").respond(json=_STRANDS_RESPONSE)
- response: Final = await router.adecisions(
+ response: Final = await router.asystemone(
model="strands",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -827,7 +827,7 @@ async def test_strands_decider_runtime_arn_sends_a_sigv4_signed_invoke_agent_run
"aws_secret_access_key": _RUNTIME_CREDENTIALS.secret_key,
}
- response: Final = await litellm.adecisions(**call_args) if use_async else litellm.decisions(**call_args)
+ response: Final = await litellm.asystemone(**call_args) if use_async else litellm.systemone(**call_args)
assert route.call_count == 1
sent: Final = route.calls[0].request
@@ -888,7 +888,7 @@ async def test_strands_decider_runtime_arn_with_api_key_sends_the_bearer_token_u
monkeypatch.delenv("STRANDS_DECIDER_API_KEY", raising=False)
route: Final = respx_mock.post(_RUNTIME_URL).respond(json=_STRANDS_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -921,7 +921,7 @@ async def test_strands_decider_runtime_error_envelope_raises_instead_of_answerin
respx_mock.post(_RUNTIME_URL).respond(json={"error": {"code": code, "message": "at most 16 questions"}})
with pytest.raises(error_class, match="at most 16 questions"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -942,7 +942,7 @@ async def test_strands_decider_plain_api_base_error_envelope_stays_an_unexpected
)
with pytest.raises(litellm.InternalServerError, match="returned an unexpected response"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="strands_decider/strands-decider-2B-hobson-v19",
state="review",
questions={"severity": {"type": "score", "criteria": ["none", "low", "high"]}},
@@ -977,7 +977,7 @@ async def test_hosted_vllm_requires_api_base_before_http(
monkeypatch.delenv("HOSTED_VLLM_API_KEY", raising=False)
with pytest.raises(litellm.BadRequestError, match="api_base is required"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="hosted_vllm/Qwen/Qwen3-0.6B",
state="review",
questions={"is_defect": {"type": "choice", "criteria": {"yes": None, "no": None}}},
@@ -995,7 +995,7 @@ async def test_hosted_vllm_without_key_sends_no_authorization_and_preserves_resp
monkeypatch.delenv("HOSTED_VLLM_API_KEY", raising=False)
route: Final = respx_mock.post("http://vllm.local:8000/v1/systemone").respond(json=_VLLM_RESPONSE)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="hosted_vllm/Qwen/Qwen3-0.6B",
state="The package arrived broken.",
questions={"is_defect": {"type": "choice", "criteria": {"yes": None, "no": None}}},
@@ -1018,7 +1018,7 @@ async def test_hosted_vllm_uses_key_and_base_from_environment(
monkeypatch.setenv("HOSTED_VLLM_API_KEY", "vllm-key")
route: Final = respx_mock.post("http://vllm.local:8000/v1/systemone").respond(json=_VLLM_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="hosted_vllm/Qwen/Qwen3-0.6B",
state="The package arrived broken.",
questions={"is_defect": {"type": "choice", "criteria": {"yes": None, "no": None}}},
@@ -1037,7 +1037,7 @@ async def test_hosted_vllm_api_base_with_v1_suffix_posts_to_v1_systemone(
monkeypatch.delenv("HOSTED_VLLM_API_KEY", raising=False)
route: Final = respx_mock.post("http://vllm.local:8000/v1/systemone").respond(json=_VLLM_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="hosted_vllm/Qwen/Qwen3-0.6B",
state="The package arrived broken.",
questions={"is_defect": {"type": "choice", "criteria": {"yes": None, "no": None}}},
@@ -1056,7 +1056,7 @@ async def test_hosted_vllm_choice_question_goes_out_as_a_jev_choice_with_the_ser
monkeypatch.delenv("HOSTED_VLLM_API_KEY", raising=False)
route: Final = respx_mock.post("http://vllm.local:8000/v1/systemone").respond(json=_VLLM_RESPONSE)
- await litellm.adecisions(
+ await litellm.asystemone(
model="hosted_vllm/Qwen/Qwen3-0.6B",
state="The package arrived broken.",
questions={
@@ -1092,7 +1092,7 @@ async def test_databricks_requires_api_base_before_http(
monkeypatch.setenv("DATABRICKS_API_KEY", "dapi-key")
with pytest.raises(litellm.BadRequestError, match="DATABRICKS_API_BASE"):
- await litellm.adecisions(
+ await litellm.asystemone(
model=f"databricks/{_DATABRICKS_ENDPOINT}",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1114,7 +1114,7 @@ async def test_databricks_rejects_a_serving_endpoint_name_that_would_rewrite_the
monkeypatch.setenv("DATABRICKS_API_KEY", "dapi-key")
with pytest.raises(litellm.BadRequestError, match="bare endpoint name"):
- await litellm.adecisions(
+ await litellm.asystemone(
model=f"databricks/{endpoint_name}",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1133,7 +1133,7 @@ async def test_databricks_requires_a_key_before_http(
monkeypatch.delenv("DATABRICKS_TOKEN", raising=False)
with pytest.raises(litellm.AuthenticationError, match="Missing API key for Decisions provider 'databricks'"):
- await litellm.adecisions(
+ await litellm.asystemone(
model=f"databricks/{_DATABRICKS_ENDPOINT}",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1162,7 +1162,7 @@ async def test_databricks_posts_the_jev_body_to_the_serving_endpoint_invocations
"sentiment": {"type": "choice", "criteria": {"positive": None, "negative": "unhappy"}},
}
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model=f"databricks/{_DATABRICKS_ENDPOINT}",
state={"ticket": "export hangs"},
questions=questions,
@@ -1206,7 +1206,7 @@ async def test_databricks_router_deployment_sends_its_own_key_to_its_own_base(
f"https://workspace.example/serving-endpoints/{_DATABRICKS_ENDPOINT}/invocations"
).respond(json=_DATABRICKS_RESPONSE)
- response: Final = await router.adecisions(
+ response: Final = await router.asystemone(
model="decider",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1260,7 +1260,7 @@ async def test_openai_decisions_translate_systemone_to_the_openai_wire_contract_
monkeypatch.delenv("OPENAI_API_BASE", raising=False)
route: Final = respx_mock.post(url).respond(json=_OPENAI_RESPONSE)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="openai/gpt-6-luna",
state="The package arrived broken.",
questions={
@@ -1345,7 +1345,7 @@ def test_openai_decisions_use_the_same_settings_as_other_openai_calls(
monkeypatch.setenv(name, value)
route: Final = respx_mock.post(url).respond(json=_OPENAI_RESPONSE)
- litellm.decisions(
+ litellm.systemone(
model="openai/gpt-6-luna",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1408,17 +1408,8 @@ async def test_openai_format_calls_to_a_systemone_provider_get_openai_format_ans
},
"cannot serve this request",
),
- (
- "openai/gpt-6-luna",
- {
- "state": "review",
- "input": "review",
- "questions": [{"type": "predicate", "instructions": "Is this a defect?"}],
- },
- "not both",
- ),
),
- ids=("image_to_systemone_provider", "state_and_input"),
+ ids=("image_to_systemone_provider",),
)
async def test_requests_a_provider_cannot_serve_are_rejected_before_http(
respx_mock: respx.MockRouter,
@@ -1451,7 +1442,7 @@ async def test_openrouter_decisions_uses_provider_reported_cost_without_cost_map
}
)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="openrouter/typesafe/jev-1.13",
state={"source": "unit-test"},
questions=_QUESTIONS,
@@ -1466,24 +1457,27 @@ _SAFETY_IDENTIFIER: Final = "end-user-7"
_PREDICATE_QUESTIONS: Final[tuple[Mapping[str, object], ...]] = (
{"type": "predicate", "name": "is_defect", "instructions": "Is this a defect?"},
)
-_PREDICATE_REQUESTS: Final[tuple[Mapping[str, object], ...]] = (
- MappingProxyType({"input": "review", "questions": _PREDICATE_QUESTIONS}),
- MappingProxyType(
- {"state": "review", "questions": {"is_defect": {"type": "noul", "instructions": "Is this a defect?"}}}
+_PREDICATE_REQUESTS: Final[tuple[tuple[str, Mapping[str, object]], ...]] = (
+ ("decisions", MappingProxyType({"input": "review", "questions": _PREDICATE_QUESTIONS})),
+ (
+ "systemone",
+ MappingProxyType(
+ {"state": "review", "questions": {"is_defect": {"type": "noul", "instructions": "Is this a defect?"}}}
+ ),
),
)
-_PREDICATE_REQUEST_IDS: Final = ("input_format", "state_format")
+_PREDICATE_REQUEST_IDS: Final = ("decisions", "systemone")
[email protected]("request_kwargs", _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
[email protected](("api", "request_kwargs"), _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
def test_safety_identifier_is_refused_before_http_when_the_provider_cannot_take_it(
- request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
+ api: str, request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setattr(litellm, "drop_params", False)
route: Final = respx_mock.post("https://api.perplexity.ai/v1/decisions").respond(json=_RESPONSE)
with pytest.raises(litellm.UnsupportedParamsError, match=r"safety_identifier.*drop_params") as caught:
- litellm.decisions(
+ getattr(litellm, api)(
model="perplexity/pplx-decider-v1-27b",
safety_identifier=_SAFETY_IDENTIFIER,
api_key="caller-key",
@@ -1524,10 +1518,11 @@ async def test_safety_identifier_is_dropped_from_the_wire_under_drop_params(
@pytest.mark.asyncio
[email protected]("request_kwargs", _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
[email protected](("api", "request_kwargs"), _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
@pytest.mark.parametrize("drop_params", (False, True), ids=("strict", "drop_params"))
async def test_safety_identifier_reaches_openai_whether_or_not_params_are_dropped(
drop_params: bool,
+ api: str,
request_kwargs: Mapping[str, object],
respx_mock: respx.MockRouter,
monkeypatch: pytest.MonkeyPatch,
@@ -1538,7 +1533,7 @@ async def test_safety_identifier_reaches_openai_whether_or_not_params_are_droppe
monkeypatch.delenv("OPENAI_API_BASE", raising=False)
route: Final = respx_mock.post("https://api.openai.com/v1/decisions").respond(json=_OPENAI_RESPONSE)
- await litellm.adecisions(
+ await getattr(litellm, f"a{api}")(
model="openai/gpt-6-luna",
safety_identifier=_SAFETY_IDENTIFIER,
api_key="caller-key",
@@ -1555,16 +1550,16 @@ async def test_safety_identifier_reaches_openai_whether_or_not_params_are_droppe
@pytest.mark.asyncio
[email protected]("request_kwargs", _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
[email protected](("api", "request_kwargs"), _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
async def test_non_string_safety_identifier_is_rejected_before_http(
- request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
+ api: str, request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setattr(litellm, "drop_params", False)
route: Final = respx_mock.post("https://api.openai.com/v1/decisions").respond(json=_OPENAI_RESPONSE)
invalid_safety_identifier: Final[Mapping[str, object]] = MappingProxyType({"safety_identifier": 7})
with pytest.raises(litellm.BadRequestError, match=r"(?s)Invalid Decisions request.*safety_identifier"):
- await litellm.adecisions(
+ await getattr(litellm, f"a{api}")(
model="openai/gpt-6-luna", api_key="caller-key", **request_kwargs, **invalid_safety_identifier
)
@@ -1572,9 +1567,9 @@ async def test_non_string_safety_identifier_is_rejected_before_http(
@pytest.mark.asyncio
[email protected]("request_kwargs", _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
[email protected](("api", "request_kwargs"), _PREDICATE_REQUESTS, ids=_PREDICATE_REQUEST_IDS)
async def test_non_string_safety_identifier_is_dropped_from_the_wire_under_drop_params(
- request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
+ api: str, request_kwargs: Mapping[str, object], respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setattr(litellm, "drop_params", False)
monkeypatch.setattr(litellm, "api_base", None)
@@ -1585,7 +1580,7 @@ async def test_non_string_safety_identifier_is_dropped_from_the_wire_under_drop_
{"safety_identifier": 7, "drop_params": True}
)
- await litellm.adecisions(
+ await getattr(litellm, f"a{api}")(
model="openai/gpt-6-luna", api_key="caller-key", **request_kwargs, **dropped_safety_identifier
)
@@ -1622,7 +1617,7 @@ async def test_azure_ai_decision_posts_deployment_to_foundry_systemone_route(
json={**_RESPONSE, "model": "microsoft-decision-1"}
)
- response: Final = await litellm.adecisions(
+ response: Final = await litellm.asystemone(
model="azure_ai/decision-1",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1654,7 +1649,7 @@ async def test_azure_ai_decision_reads_foundry_env_and_keeps_gateway_path_prefix
json=_RESPONSE
)
- await litellm.adecisions(
+ await litellm.asystemone(
model="azure_ai/decision-1",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
@@ -1673,7 +1668,7 @@ async def test_azure_ai_decision_requires_api_base_before_http(
monkeypatch.setenv("AZURE_AI_API_KEY", "foundry-key")
with pytest.raises(litellm.BadRequestError, match="Missing AZURE_AI_API_BASE"):
- await litellm.adecisions(
+ await litellm.asystemone(
model="azure_ai/decision-1",
state="review",
questions={"is_defect": {"type": "noul", "instructions": "Is this a defect?"}},
diff --git a/tests/unit/llms/azure/test_azure_common_utils.py b/tests/unit/llms/azure/test_azure_common_utils.py
index 302175c46f8..b277cac1f29 100644
--- a/tests/unit/llms/azure/test_azure_common_utils.py
+++ b/tests/unit/llms/azure/test_azure_common_utils.py
@@ -471,6 +471,7 @@ def test_default_max_retries_env_var_reaches_azure_sdk_client():
"llm_passthrough_route",
"asearch",
"adecisions",
+ "asystemone",
"avector_store_create",
"avector_store_search",
"acreate_skill",
diff --git a/tests/unit/systemone/__init__.py b/tests/unit/systemone/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/unit/systemone/test_main.py b/tests/unit/systemone/test_main.py
new file mode 100644
index 00000000000..342b7f1ef97
--- /dev/null
+++ b/tests/unit/systemone/test_main.py
@@ -0,0 +1,138 @@
+from __future__ import annotations
+
+import asyncio
+import json
+from collections.abc import Mapping
+from types import MappingProxyType
+from typing import Final
+
+import pytest
+import respx
+from respx.models import Call
+
+import litellm
+from litellm.integrations.custom_logger import CustomLogger
+from litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKER
+from litellm.types.decisions import DecisionsResponse, OpenAIDecisionResponse
+
+_STATE: Final = "Customer asked for a refund"
+_SYSTEMONE_QUESTIONS: Final[Mapping[str, object]] = MappingProxyType(
+ {"is_refund": {"type": "noul", "instructions": "Is this a refund request?"}}
+)
+_OPENAI_QUESTIONS: Final[tuple[Mapping[str, object], ...]] = (
+ {"type": "predicate", "name": "is_refund", "instructions": "Is this a refund request?"},
+)
+_SYSTEMONE_RESPONSE: Final[Mapping[str, object]] = {
+ "model": "jev-1.13",
+ "answers": {"is_refund": {"type": "noul", "noul": 0.93}},
+ "usage": {"input_tokens": 12, "output_tokens": 1},
+}
+_TYPESAFE_URL: Final = "https://api.typesafe.ai/v1/systemone"
+
+
[email protected](autouse=True)
+def _httpx_transport(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
+ litellm.in_memory_llm_clients_cache.flush_cache()
+
+
+class _CallTypeRecorder(CustomLogger):
+ def __init__(self) -> None:
+ super().__init__()
+ self.call_types: list[str] = [] # mutable-ok: test recorder collects logger callbacks
+
+ async def async_log_success_event(self, kwargs, response_obj, start_time, end_time) -> None:
+ self.call_types.append(kwargs["call_type"])
+
+
[email protected]("use_async", (True, False), ids=("asystemone", "systemone"))
+async def test_systemone_sends_the_systemone_wire_format_and_returns_a_systemone_response(
+ use_async: bool, respx_mock: respx.MockRouter
+) -> None:
+ route: Final = respx_mock.post(_TYPESAFE_URL).respond(json=_SYSTEMONE_RESPONSE)
+ kwargs: Final[Mapping[str, object]] = MappingProxyType(
+ {"model": "typesafe/jev-1.13", "state": _STATE, "questions": _SYSTEMONE_QUESTIONS, "api_key": "caller-key"}
+ )
+
+ response: Final = await litellm.asystemone(**kwargs) if use_async else litellm.systemone(**kwargs)
+
+ assert route.called
+ call: Final[Call] = respx_mock.calls.last
+ assert json.loads(call.request.content) == {
+ "model": "jev-1.13",
+ "state": _STATE,
+ "questions": {"is_refund": {"type": "noul", "instructions": "Is this a refund request?"}},
+ }
+ assert isinstance(response, DecisionsResponse)
+ assert response.answers["is_refund"].model_dump(mode="json") == {"type": "noul", "noul": 0.93}
+
+
+async def test_systemone_rejects_openai_input_and_points_at_decisions(respx_mock: respx.MockRouter) -> None:
+ route: Final = respx_mock.post(_TYPESAFE_URL).respond(json=_SYSTEMONE_RESPONSE)
+
+ with pytest.raises(litellm.BadRequestError, match=r"litellm\.decisions") as caught:
+ await litellm.asystemone(
+ model="typesafe/jev-1.13", input=_STATE, questions=_SYSTEMONE_QUESTIONS, api_key="caller-key"
+ )
+
+ assert caught.value.status_code == 400
+ assert not route.called
+
+
[email protected]("use_async", (True, False), ids=("adecisions", "decisions"))
+async def test_decisions_with_state_still_sends_the_systemone_format_and_warns(
+ use_async: bool, respx_mock: respx.MockRouter
+) -> None:
+ route: Final = respx_mock.post(_TYPESAFE_URL).respond(json=_SYSTEMONE_RESPONSE)
+ kwargs: Final[Mapping[str, object]] = MappingProxyType(
+ {"model": "typesafe/jev-1.13", "state": _STATE, "questions": _SYSTEMONE_QUESTIONS, "api_key": "caller-key"}
+ )
+
+ with pytest.warns(UserWarning, match=r"litellm\.systemone"):
+ response: Final = await litellm.adecisions(**kwargs) if use_async else litellm.decisions(**kwargs)
+
+ assert route.called
+ call: Final[Call] = respx_mock.calls.last
+ assert json.loads(call.request.content) == {
+ "model": "jev-1.13",
+ "state": _STATE,
+ "questions": {"is_refund": {"type": "noul", "instructions": "Is this a refund request?"}},
+ }
+ assert isinstance(response, DecisionsResponse)
+ assert response.answers["is_refund"].model_dump(mode="json") == {"type": "noul", "noul": 0.93}
+
+
+async def test_systemone_rejects_openai_question_lists_before_http(respx_mock: respx.MockRouter) -> None:
+ route: Final = respx_mock.post(_TYPESAFE_URL).respond(json=_SYSTEMONE_RESPONSE)
+
+ with pytest.raises(litellm.BadRequestError, match="Invalid Decisions request"):
+ await litellm.asystemone(
+ model="typesafe/jev-1.13", state=_STATE, questions=_OPENAI_QUESTIONS, api_key="caller-key"
+ )
+
+ assert not route.called
+
+
+async def test_router_asystemone_logs_the_systemone_call_type(
+ respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ respx_mock.post(_TYPESAFE_URL).respond(json=_SYSTEMONE_RESPONSE)
+ recorder: Final = _CallTypeRecorder()
+ monkeypatch.setattr(litellm, "callbacks", [recorder])
+ router: Final = litellm.Router(
+ model_list=[{"model_name": "jev", "litellm_params": {"model": "typesafe/jev-1.13", "api_key": "caller-key"}}]
+ )
+
+ response: Final = await router.asystemone(model="jev", state=_STATE, questions=_SYSTEMONE_QUESTIONS)
+ await asyncio.sleep(0)
+ GLOBAL_LOGGING_WORKER.start()
+ await asyncio.wait_for(GLOBAL_LOGGING_WORKER.flush(), timeout=10.0)
+
+ assert isinstance(response, DecisionsResponse)
+ assert recorder.call_types == ["asystemone"]
+ assert not isinstance(response, OpenAIDecisionResponse)
diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts
index 05e80d26e09..a02517dd72d 100644
--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts
+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts
@@ -28065,7 +28065,7 @@ export interface components {
* CallTypes
* @enum {string}
*/
- CallTypes: "embedding" | "aembedding" | "completion" | "acompletion" | "atext_completion" | "text_completion" | "image_generation" | "aimage_generation" | "image_edit" | "aimage_edit" | "moderation" | "amoderation" | "atranscription" | "transcription" | "aspeech" | "speech" | "rerank" | "arerank" | "search" | "asearch" | "decisions" | "adecisions" | "_arealtime" | "_aresponses_websocket" | "create_batch" | "acreate_batch" | "aretrieve_batch" | "retrieve_batch" | "acancel_batch" | "cancel_batch" | "pass_through_endpoint" | "anthropic_messages" | "aanthropic_messages" | "get_assistants" | "aget_assistants" | "create_assistants" | "acreate_assistants" | "delete_assistant" | "adelete_assistant" | "acreate_thread" | "create_thread" | "aget_thread" | "get_thread" | "a_add_message" | "add_message" | "aget_messages" | "get_messages" | "arun_thread" | "run_thread" | "arun_thread_stream" | "run_thread_stream" | "afile_retrieve" | "file_retrieve" | "afile_delete" | "file_delete" | "afile_list" | "file_list" | "acreate_file" | "create_file" | "afile_content" | "file_content" | "create_fine_tuning_job" | "acreate_fine_tuning_job" | "create_video" | "acreate_video" | "video_generation" | "avideo_generation" | "avideo_retrieve" | "video_retrieve" | "avideo_content" | "video_content" | "video_remix" | "avideo_remix" | "video_list" | "avideo_list" | "video_retrieve_job" | "avideo_retrieve_job" | "video_delete" | "avideo_delete" | "video_create_character" | "avideo_create_character" | "video_get_character" | "avideo_get_character" | "video_edit" | "avideo_edit" | "video_extension" | "avideo_extension" | "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" | "vector_store_create" | "avector_store_create" | "vector_store_search" | "avector_store_search" | "ingest" | "aingest" | "query" | "aquery" | "create_interaction" | "acreate_interaction" | "create_container" | "acreate_container" | "list_containers" | "alist_containers" | "retrieve_container" | "aretrieve_container" | "delete_container" | "adelete_container" | "list_container_files" | "alist_container_files" | "upload_container_file" | "aupload_container_file" | "create_sandbox" | "acreate_sandbox" | "delete_sandbox" | "adelete_sandbox" | "run_code" | "arun_code" | "code_interpreter_tool" | "acode_interpreter_tool" | "acancel_fine_tuning_job" | "cancel_fine_tuning_job" | "alist_fine_tuning_jobs" | "list_fine_tuning_jobs" | "aretrieve_fine_tuning_job" | "retrieve_fine_tuning_job" | "responses" | "aresponses" | "alist_input_items" | "llm_passthrough_route" | "allm_passthrough_route" | "generate_content" | "agenerate_content" | "generate_content_stream" | "agenerate_content_stream" | "ocr" | "aocr" | "call_mcp_tool" | "list_mcp_tools" | "asend_message" | "send_message" | "acreate_skill";
+ CallTypes: "embedding" | "aembedding" | "completion" | "acompletion" | "atext_completion" | "text_completion" | "image_generation" | "aimage_generation" | "image_edit" | "aimage_edit" | "moderation" | "amoderation" | "atranscription" | "transcription" | "aspeech" | "speech" | "rerank" | "arerank" | "search" | "asearch" | "decisions" | "adecisions" | "systemone" | "asystemone" | "_arealtime" | "_aresponses_websocket" | "create_batch" | "acreate_batch" | "aretrieve_batch" | "retrieve_batch" | "acancel_batch" | "cancel_batch" | "pass_through_endpoint" | "anthropic_messages" | "aanthropic_messages" | "get_assistants" | "aget_assistants" | "create_assistants" | "acreate_assistants" | "delete_assistant" | "adelete_assistant" | "acreate_thread" | "create_thread" | "aget_thread" | "get_thread" | "a_add_message" | "add_message" | "aget_messages" | "get_messages" | "arun_thread" | "run_thread" | "arun_thread_stream" | "run_thread_stream" | "afile_retrieve" | "file_retrieve" | "afile_delete" | "file_delete" | "afile_list" | "file_list" | "acreate_file" | "create_file" | "afile_content" | "file_content" | "create_fine_tuning_job" | "acreate_fine_tuning_job" | "create_video" | "acreate_video" | "video_generation" | "avideo_generation" | "avideo_retrieve" | "video_retrieve" | "avideo_content" | "video_content" | "video_remix" | "avideo_remix" | "video_list" | "avideo_list" | "video_retrieve_job" | "avideo_retrieve_job" | "video_delete" | "avideo_delete" | "video_create_character" | "avideo_create_character" | "video_get_character" | "avideo_get_character" | "video_edit" | "avideo_edit" | "video_extension" | "avideo_extension" | "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" | "vector_store_create" | "avector_store_create" | "vector_store_search" | "avector_store_search" | "ingest" | "aingest" | "query" | "aquery" | "create_interaction" | "acreate_interaction" | "create_container" | "acreate_container" | "list_containers" | "alist_containers" | "retrieve_container" | "aretrieve_container" | "delete_container" | "adelete_container" | "list_container_files" | "alist_container_files" | "upload_container_file" | "aupload_container_file" | "create_sandbox" | "acreate_sandbox" | "delete_sandbox" | "adelete_sandbox" | "run_code" | "arun_code" | "code_interpreter_tool" | "acode_interpreter_tool" | "acancel_fine_tuning_job" | "cancel_fine_tuning_job" | "alist_fine_tuning_jobs" | "list_fine_tuning_jobs" | "aretrieve_fine_tuning_job" | "retrieve_fine_tuning_job" | "responses" | "aresponses" | "alist_input_items" | "llm_passthrough_route" | "allm_passthrough_route" | "generate_content" | "agenerate_content" | "generate_content_stream" | "agenerate_content_stream" | "ocr" | "aocr" | "call_mcp_tool" | "list_mcp_tools" | "asend_message" | "send_message" | "acreate_skill";
/** CallbackDelete */
CallbackDelete: {
/** Callback Name */