Models Service#
- class saia_python.models.ModelsService(session: requests.Session, base_url: str, *, timeout: float | tuple[float, float] | None = (10.0, 60.0))[source]#
Access the
/modelsendpoint.- Parameters:
session – A
requests.Sessionwith auth headers configured.base_url – The SAIA API base URL (e.g.
https://chat-ai.academiccloud.de/v1).timeout – Default
(connect, read)timeout in seconds for theGET /modelslisting call, so it fails fast instead of hanging forever when the server accepts the request but never responds. A singlefloatapplies to both phases; passNoneto disable. Defaults to(10, 60). (The tool-capability probe keeps its own per-requesttimeout.)
- list_raw() dict[source]#
Return the raw
/modelsresponse envelope, as the API sent it.Unlike
list(), this does not unwrap the OpenAI-style{"object": "list", "data": [...]}envelope — it returns the parsed JSON verbatim. Use it when you need the full OpenAI-compatible payload, e.g. an adapter that re-serves SAIA’s models at its ownGET /v1/modelsendpoint:return client.models.list_raw() # already the OpenAI envelope
- Returns:
The parsed JSON response. For the SAIA / OpenAI-compatible API this is a dict of the form
{"object": "list", "data": [...]}.
- list() list[dict][source]#
Return the full model list as returned by the API.
- Returns:
A list of model dicts, each containing at least an
"id"key.
- list_tool_capable(*, verbose: bool = False) list[str][source]#
Identify models that support tool calling by probing each one.
Sends a minimal tool-calling request to each available model and checks whether the response contains a
tool_callsfield. This is a trial-and-error approach because the SAIA API does not expose tool support as model metadata.- Parameters:
verbose – If
True, print per-model results during probing.- Returns:
A list of model ID strings that responded with a tool call.
Note
This method consumes API quota (one request per model) and may take several minutes depending on the number of available models.