SDKs#

Termite provides type-safe client libraries for Go and TypeScript, auto-generated from the OpenAPI specification. Termite also exposes an Ollama-compatible /api/embed endpoint, so any Ollama client library works for embedding generation.

LanguagePackageRegistrySource
Gogithub.com/antflydb/termite/pkg/clientpkg.go.devGitHub
TypeScript@antfly/termite-sdknpmGitHub

Installation#

go get github.com/antflydb/termite/pkg/client

Quick Start#

Generate Embeddings#

import (
	"context"
	"net/http"
	"github.com/antflydb/termite/pkg/client"
)

c, err := client.NewTermiteClient("http://localhost:8080", &http.Client{})
if err != nil {
	log.Fatal(err)
}

embeddings, err := c.Embed(
	context.Background(),
	"bge-small-en-v1.5",
	[]string{"hello world", "semantic search"},
)
if err != nil {
	log.Fatal(err)
}

// embeddings is [][]float32
fmt.Printf("dimensions: %d\n", len(embeddings[0]))

Chunk Text#

// Use the Termite HTTP API directly for chunking
import "net/http"

req, _ := http.NewRequest("POST", "http://localhost:8080/api/chunk", strings.NewReader(`{
	"text": "Your long document text goes here...",
	"config": {
		"model": "fixed",
		"target_tokens": 500
	}
}`))
req.Header.Set("Content-Type", "application/json")

resp, err := http.DefaultClient.Do(req)

Rerank Results#

// Use the Termite HTTP API directly for reranking
import "net/http"

req, _ := http.NewRequest("POST", "http://localhost:8080/api/rerank", strings.NewReader(`{
	"model": "bge-reranker-v2-m3",
	"query": "what is semantic search?",
	"documents": [
		"Semantic search uses embeddings to find relevant results.",
		"Keyword search matches exact terms in documents.",
		"Vector databases store high-dimensional embeddings."
	]
}`))
req.Header.Set("Content-Type", "application/json")

resp, err := http.DefaultClient.Do(req)

Ollama Compatibility#

Termite implements the Ollama /api/embed endpoint, so any Ollama client library can generate embeddings from Termite. This is useful if you already use Ollama in your stack and want to swap in Termite for ONNX-based inference.

# Works with the Ollama API format
curl -X POST http://localhost:8080/api/embed \
  -H "Content-Type: application/json" \
  -d '{"model": "bge-small-en-v1.5", "input": ["hello world"]}'

See the API Reference for the full list of endpoints.