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 /models endpoint.

Parameters:
  • session – A requests.Session with 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 the GET /models listing call, so it fails fast instead of hanging forever when the server accepts the request but never responds. A single float applies to both phases; pass None to disable. Defaults to (10, 60). (The tool-capability probe keeps its own per-request timeout.)

list_raw() dict[source]#

Return the raw /models response 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 own GET /v1/models endpoint:

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_ids() list[str][source]#

Return a deduplicated list of model ID strings.

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_calls field. 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.