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: Mapping[str, str] | None = None, http_client: Client | None = None)[source]

Bases: object

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.

http

The http transport, for endpoints that the SDK does not wrap.

property api_key: str

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

property base_url: str

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

property manifests: Manifests

The manifest api, for any resource kind.

property llm_clients: LLMClients

LLMClients.

property guardrails: Guardrails

Guardrails.

property mcp_clients: MCPClients

MCPClients.

property vectorstores: Vectorstores

Vectorstores.

property llm_hosts: LLMHosts

LLMHosts.

property secrets: Secrets

Secrets.

property plugins: Plugins

Plugins.

property orchestrators: Orchestrators

Orchestrators.

property vectorsearches: Vectorsearches

Vectorsearches.

property accounts: Accounts

Accounts, and their users and contacts.

property history: PromptHistory

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

property journal: Journal

The Smarter Journal.

Superusers only.

property providers: Providers

LLM providers and their models.

property proxies: Proxies

Proxies to LLM providers’ own apis.

whoami() → WhoAmI[source]

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

Returns:

The owner.

version() → PlatformVersion[source]

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

Returns:

The versions.

status() → PlatformStatus[source]

The state of the platform’s infrastructure and compute.

Returns:

The status.

kinds() → list[KindInfo][source]

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

Returns:

The kinds.

close() → None[source]

Close the client’s connections.