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.
| Language | Package | Registry | Source |
|---|---|---|---|
| Go | github.com/antflydb/termite/pkg/client | pkg.go.dev | GitHub |
| TypeScript | @antfly/termite-sdk | npm | GitHub |
Installation
go get github.com/antflydb/termite/pkg/clientnpm install @antfly/termite-sdkQuick 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]))import { TermiteClient } from '@antfly/termite-sdk';
const client = new TermiteClient({
baseUrl: 'http://localhost:8080/api',
});
const result = await client.embed(
'bge-small-en-v1.5',
['hello world', 'semantic search'],
);
console.log('dimensions:', result.embeddings[0].length);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)const chunks = await client.chunk(
'Your long document text goes here...',
{ model: 'fixed', target_tokens: 500 },
);
for (const chunk of chunks.chunks) {
console.log(chunk.text);
}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)const ranked = await client.rerank(
'bge-reranker-v2-m3',
'what is semantic search?',
[
'Semantic search uses embeddings to find relevant results.',
'Keyword search matches exact terms in documents.',
'Vector databases store high-dimensional embeddings.',
],
);
for (const result of ranked.results) {
console.log(result.index, result.relevance_score);
}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.