Skip to content

Developers

Build with Toskar

Official SDKs for building on the AI that runs on your own computers: chat with streamed answers, models, knowledge, automations, files, and events, from your own code.

Quick start

TypeScript and JavaScript

The toskar package is on npm, as a preview. With Toskar running on this computer, the quick start prints an answer from a model on it.

Install
npm install toskar
Stream an answer
import { Toskar } from "toskar";

// This computer's Toskar Core needs no key. Elsewhere:
// new Toskar({ baseUrl: "http://studio.local:7331", apiKey: "tk_…" })
const toskar = new Toskar();

for await (const event of toskar.chatStream({ message: "Plan a three-day trip to Juneau" })) {
  if (event.type === "token") process.stdout.write(event.content);
}

More in the TypeScript SDK's guide.

Quick start

Python

The toskar package for Python is on PyPI, a preview too, sync and async (AsyncToskar).

Install
pip install toskar
Stream an answer
from toskar import Toskar

# This computer's Toskar Core needs no key. Elsewhere:
# Toskar("http://studio.local:7331", api_key="tk_…")
toskar = Toskar()

for event in toskar.chat_stream("Plan a three-day trip to Juneau"):
    if event.type == "token":
        print(event.content, end="", flush=True)

models = toskar.api.list_models()  # every route, typed

More in the Python SDK's guide.

Quick start

Go

The Go module is a preview: streamed answers and events are Go iterators, and package api has every route, typed.

Install
go get github.com/yeixio/toskar-sdks/go
Stream an answer
c, err := toskar.New() // this computer; or toskar.WithURL(…), toskar.WithKey(…)
if err != nil {
	return err
}
req := api.ChatJSONRequestBody{Message: "Plan a three-day trip to Juneau"}
for e, err := range c.ChatStream(ctx, req) {
	if err != nil {
		return err
	}
	if e.Type == "token" {
		fmt.Print(e.Content)
	}
}

models, err := toskar.Data(c.ListModelsWithResponse(ctx)) // every route, typed

More in the Go SDK's guide.

What you get

One API, typed in your language

  • Every route, typed

    Generated from Toskar Core's API spec: chat, models, knowledge, automations, files, people, computers, and events, with request and answer types for each.

  • Answers as they're written

    Streamed chat and the events stream are async iteration in each language. A stream that fails says why, with a code.

  • Errors you can act on

    Every error has a stable code, such as NO_MODEL_INSTALLED, and the values it needs, so your app can say what to do next.

  • Kept in step with Core

    Core's tests hold its API to the spec, and the SDKs are regenerated when Core has a new release. Each one says which contract it was built for.

Every route

The whole API, with its types

Any route
import { Toskar, unwrap } from "toskar";

const toskar = new Toskar();
const models = unwrap(await toskar.api.GET("/api/v1/models"));
const chat = unwrap(await toskar.api.POST("/api/v1/conversations", { body: { title: "Trip" } }));
Errors and events
import { ErrorCodes, ToskarError } from "toskar";

try {
  await toskar.chat({ message: "Hi" });
} catch (err) {
  if (err instanceof ToskarError && err.code === ErrorCodes.NO_MODEL_INSTALLED) {
    // Install one first: POST /api/v1/models/{id}/install
  }
}

for await (const event of toskar.events()) {
  console.log(event.type); // such as model.download.progress or automation.completed
}

Languages

SDKs, and what's next

LanguagePackageStatus
TypeScript and JavaScripttoskar, for Node, Deno, Bun, and browsersPreview
Pythontoskar, sync and async, for Python 3.10 and laterPreview
Gogithub.com/yeixio/toskar-sdks/go, for Go 1.24 and laterPreview
Swift, Kotlin and Java, C# and .NET, RustFrom the same specLater

In any other language, call the API directly: the OpenAPI spec describes every route, and the OpenAI-compatible routes work with OpenAI's own SDKs (see Toskar for developers).

Good to know

Connecting and versions

  • This computer needs no key. Toskar Core answers on http://127.0.0.1:7331. Anywhere else needs an API key, from API Access; the SDKs also read TOSKAR_URL and TOSKAR_API_KEY.
  • Like the Toskar apps, soon. Connecting with a code from Connect a device, checking a computer's certificate, and reaching it from anywhere through the relay are coming to the SDKs next.
  • Versions. Each SDK says which client contract it was built for. Toskar Core keeps the contract compatible within a major version, and tells an app built for another one to update.
  • Apache 2.0. The SDKs are yours to use in any app; Toskar Core itself is open source under the AGPL.