Smarter Python SDK
The Smarter Python SDK is the official Python library of the Smarter API. It is
to Smarter what the openai package is to the OpenAI API: one pip install gives your Python
software typed, complete access to your own Smarter platform, whether it runs on your laptop or on
Kubernetes.
Use it to build custom software that is tightly integrated with your Smarter resources, without customizing or forking the Smarter platform: a web application that chats with your LLMClients, a CI/CD job that applies your manifests, a data pipeline that loads documents into a Vectorstore, a service that calls the tools of your MCP servers, or a test suite for your prompts.
pip install smarter-api
from smarter import Smarter
client = Smarter() # SMARTER_API_KEY, or the smarter cli's ~/.smarter/config.yaml
llmclient = client.llm_clients.find("customer_support")
response = client.llm_clients.prompt(llmclient.id, "Where is my order #1234?")
print(response.text)
The package is smarter-api on PyPI, and its import
name is smarter. Its source is
github.com/smarter-sh/smarter-python.
The SDK or the CLI?
The SDK and the Smarter CLI manage the same resources, through the same API. The difference is how you use them.
Smarter Python SDK |
Smarter CLI |
|---|---|
A Python library that you import into your own software. |
A program that you install on your computer. |
|
|
Returns typed Pydantic models, and raises typed exceptions. |
Prints JSON or YAML in a terminal window. |
For applications, services, notebooks, tests and automation. |
For people at a keyboard, and shell scripts. |
The SDK reads the CLI’s configuration file, so a developer who has run smarter configure needs
no other setup.
What It Covers
Every resource kind, through the same brokered manifest API that the CLI uses:
apply,validate,get,describe,delete,deploy,undeployandlogs.Prompts and conversations: prompt an LLMClient, hold a multi-turn chat that keeps its session, and stream a prompt’s progress as it runs, exactly as Smarter Chat does.
Resource actions: evaluate a Guardrail, call an MCP server’s tools, add documents to and search a Vectorstore, plan and deploy an LLMHost, discover open-weight models, read the chat history and the Smarter Journal, and call an LLM provider through a Proxy.
The platform’s own Pydantic models: a typed model of every manifest kind, the Smarter Chat API contract, the Smarter Journal contract and the Django-React integration contract.
Where to Start
If you want to… |
Read |
|---|---|
Connect to your platform: api keys, urls, environments, timeouts |
|
Create, change and delete resources from Python |
|
Prompt an LLMClient, chat with it, or stream its progress |
|
Use Guardrails, MCP clients, Vectorstores, LLMHosts and the other resources |
|
Build manifests in code, or read the API’s contracts as typed models |
|
Handle errors, retries, timeouts and logging |
|
Contribute to the SDK |
|
Look up a class or method |