The Client

smarter.client

The Smarter client.

from smarter import Smarter

client = Smarter()                      # SMARTER_API_KEY, or ~/.smarter/config.yaml
print(client.whoami().user.username)

response = client.llm_clients.prompt(5, "What is 17 times 23?")
print(response.text)
class smarter.client.Smarter(*, api_key: str | None = None, base_url: str | None = None, environment: Literal['local', 'alpha', 'beta', 'next', 'prod'] | None = None, timeout: float | None = None, max_retries: int | None = None, default_headers: collections.abc.Mapping[str, str] | None = None, http_client: httpx.Client | None = None) → None

A client of a Smarter platform’s api.

Every argument is optional. See smarter.core.conf for where each is looked up.

Parameters:
  • api_key – A Smarter api key.

  • base_url – The platform’s url, e.g. https://platform.example.com or http://localhost:9357.

  • environment – The environment of the smarter cli’s configuration file to use: local, alpha, beta, next or prod.

  • timeout – The request timeout, in seconds.

  • max_retries – How many times to retry a request that failed for a transient reason, e.g. a timeout, a 429 or a 502. 0 disables retries.

  • default_headers – Headers to add to every request.

  • http_client – An httpx.Client to send the requests, e.g. one with a proxy. The client does not close a client that it was given.

Raises:

SmarterConfigurationError – If no api key is found.

The client’s attributes group the api’s operations:

Use it as a context manager, or call close(), to close its connections.

property api_key

The api key, e.g. to use a proxy with a provider’s own SDK.

property base_url

The api’s base url, e.g. https://platform.smarter.sh/api/v1/.

property manifests

The manifest api, for any resource kind.

property llm_clients

LLMClients.

property guardrails

Guardrails.

property mcp_clients

MCPClients.

property vectorstores

Vectorstores.

property llm_hosts

LLMHosts.

property secrets

Secrets.

property plugins

Plugins.

property orchestrators

Orchestrators.

property vectorsearches

Vectorsearches.

property accounts

Accounts, and their users and contacts.

property history

The history of chat sessions, tool calls and plugin uses.

property journal

The Smarter Journal.

Superusers only.

property providers

LLM providers and their models.

property proxies

Proxies to LLM providers’ own apis.

whoami() → smarter.models.platform.WhoAmI

The owner of the api key: the user, their account, and the platform’s environment.

Returns:

The owner.

version() → smarter.models.platform.PlatformVersion

The platform’s version, and the versions of its main Python packages.

Returns:

The versions.

status() → smarter.models.platform.PlatformStatus

The state of the platform’s infrastructure and compute.

Returns:

The status.

kinds() → list[smarter.models.manifest.KindInfo]

The resource kinds that the platform supports, and which of them can be deployed.

Returns:

The kinds.

close() → None

Close the client’s connections.