Smarter Go SDK

The Smarter Go SDK is the official Go library of the Smarter API. It is to Smarter what openai-go is to the OpenAI API: one go get gives your Go 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 service that chats with your LLMClients, a Kubernetes operator or CI/CD job that applies your manifests, a pipeline that loads documents into a Vectorstore, or a tool that calls the tools of your MCP servers.

go get github.com/smarter-sh/smarter-golang
client, err := smarter.NewClient() // SMARTER_API_KEY, or the smarter cli's ~/.smarter/config.yaml
if err != nil {
    log.Fatal(err)
}
ctx := context.Background()
llmclient, err := client.LLMClients.Find(ctx, "customer_support")
if err != nil {
    log.Fatal(err)
}
response, err := client.LLMClients.Prompt(ctx, llmclient.Ref(), smarter.Text("Where is my order #1234?"), nil)
if err != nil {
    log.Fatal(err)
}
fmt.Println(response.Text())

The module is github.com/smarter-sh/smarter-golang, and its package is smarter. Its API reference is on pkg.go.dev, with runnable examples, and its source is github.com/smarter-sh/smarter-golang. It supports the Go releases that the Go team supports.

It has the same features as the Smarter Python SDK, which is the reference implementation of every Smarter SDK: the same resources, the same verbs and the same errors, with Go names (client.LLMClients, ExampleManifest), a context.Context on every call, and errors for errors.Is and errors.As.

The SDK or the CLI?

The SDK and the Smarter CLI manage the same resources, through the same API, and both are written in Go. The difference is how you use them.

Smarter Go SDK

Smarter CLI

A library that you import into your own software.

A program that you install on your computer.

client.Manifests.Apply(ctx, manifest)

smarter apply -f guardrail.yaml

Returns typed structs, and errors for errors.Is and errors.As.

Prints JSON or YAML in a terminal window.

For services, operators, tests and automation.

For people at a keyboard, and shell scripts.

The SDK reads the CLI’s configuration file exactly as the CLI does, 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, Undeploy and Logs.

  • 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 models: a Go struct of every manifest kind, in the sam package, generated from the platform’s JSON Schemas, and 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

Configuration

Create, change and delete resources from Go

Manifests

Prompt an LLMClient, chat with it, or stream its progress

Prompts and Chat

Use Guardrails, MCP clients, Vectorstores, LLMHosts and the other resources

Resources

Build manifests in code, or read the API’s contracts as structs

Models

Handle errors, retries, timeouts, cancellation and logging

Errors and Reliability

Contribute to the SDK

Developing the SDK

Look up a type or method

pkg.go.dev