SDKs#

Antfly provides type-safe client libraries for Go, TypeScript, Python, and Rust. The Go, TypeScript, and Python SDKs are hand-written clients over code generated from the OpenAPI specification; the Rust SDK is generated from it end to end.

LanguagePackageRegistrySource
Gogithub.com/antflydb/antfly/go/pkg/sdkpkg.go.devGitHub
TypeScript@antfly/sdknpmGitHub
Pythonantfly-sdkPyPIGitHub
Rustantfly-sdkNot yet published; use a git dependencyGitHub

For TypeScript SQL queries, see the Kysely reference for embedded and server connections, typed search composition, schema generation, and migrations.

Embedded Bindings#

The embedded packages wrap one libantfly C ABI. They open .aflite files or single-node directory databases, and expose inference without opening a database. Each language binding passes the shared conformance cases:

LanguagePackageSource
Gogithub.com/antflydb/antfly/go/pkg/embeddedgo/pkg/embedded
Pythonantfly-embedded (import antfly_embedded)py/packages/embedded
Rustantfly-embeddedrs/crates/embedded
TypeScript (Node)@antfly/embeddedts/packages/embedded

Use an SDK to connect to a running Antfly service; use an embedded binding for local databases or in-process inference. Python and npm platform packages include libantfly; direct C and Go/Rust consumers can use the Apache Embedded release archive. The .aflite storage format and antfly lite commands keep their Lite names.

See the Antfly Lite guide for CLI and embedded examples, plus backup, restore, and promotion between Lite and a running instance.

Installation#

These examples target the development API at source revision ddba6584b38b59c62e261ef63e0374dc1f711617. Registry contents inspected on 2026-10-22: PyPI 0.0.2.dev2 lacks query; TestPyPI 0.0.1 lacks read-requirement helpers and media chunking; npm 0.0.14 lacks readAfterWrite, read_requirements, and media chunking. Use the pinned source routes below for these APIs until compatible network SDK releases are published. The Python source route requires Git and Python 3.11+; the TypeScript recipe requires the pinned Node/pnpm toolchain (or Volta). Registry installation alone does not select this development contract.

For TypeScript, build and pack the SDK from the repository root:

git clone https://github.com/antflydb/antfly.git antfly-sdk-source
cd antfly-sdk-source
git checkout ddba6584b38b59c62e261ef63e0374dc1f711617
cd ts
node scripts/run-pinned-toolchain.mjs pnpm install --frozen-lockfile
node scripts/run-pinned-toolchain.mjs pnpm --filter @antfly/sdk build
node scripts/run-pinned-toolchain.mjs pnpm --filter @antfly/sdk pack --pack-destination /tmp
# In your application:
npm install /tmp/antfly-sdk-0.2.0.tgz
go get github.com/antflydb/antfly/go/pkg/sdk@ddba6584b38b59c62e261ef63e0374dc1f711617

Authentication#

All three authentication methods are supported across SDKs: basic auth, API key, and token.

Basic Auth#

import (
	antfly "github.com/antflydb/antfly/go/pkg/sdk"
	"github.com/antflydb/antfly/go/pkg/sdk/oapi"
)

client, err := antfly.NewAntflyClientWithOptions(
	"http://127.0.0.1:8080",
	oapi.WithRequestEditorFn(antfly.WithBasicAuth("admin", "password")),
)

API Key#

client, err := antfly.NewAntflyClientWithOptions(
	"http://127.0.0.1:8080",
	oapi.WithRequestEditorFn(antfly.WithApiKey("key-id", "key-secret")),
)

Token#

The bearer token is an API key encoded as base64(key_id:key_secret), the same value the ApiKey scheme takes (the key's encoded field when it is created).

client, err := antfly.NewAntflyClientWithOptions(
	"http://127.0.0.1:8080",
	oapi.WithRequestEditorFn(antfly.WithToken("your-token")),
)

Quick Start#

Insert Documents#

import (
	"context"
	"log"

	antfly "github.com/antflydb/antfly/go/pkg/sdk"
	"github.com/antflydb/antfly/go/pkg/sdk/oapi"
)

ctx := context.Background()
client, err := antfly.NewAntflyClientWithOptions(
	"http://127.0.0.1:8080",
	oapi.WithRequestEditorFn(antfly.WithBasicAuth("admin", "password")),
)
if err != nil {
	log.Fatal(err)
}

// Batch insert documents
result, err := client.Batch(ctx, "products", antfly.BatchRequest{
	Inserts: map[string]any{
		"prod:001": map[string]any{
			"name":  "Laptop",
			"price": 1299.99,
		},
		"prod:002": map[string]any{
			"name":  "Mouse",
			"price": 29.99,
		},
	},
})

Query#

import "github.com/antflydb/antfly/go/pkg/sdk/query"

fullText := query.NewQueryString("laptop")
results, err := client.Query(ctx, antfly.QueryRequest{
	Table:          "products",
	FullTextSearch: &fullText,
	Limit:          10,
})
if err != nil {
	log.Fatal(err)
}

for _, hit := range results.Responses[0].Hits.Hits {
	fmt.Printf("%s: %v\n", hit.ID, hit.Source)
}

Rust has no query sample. Its client is generated straight from the OpenAPI spec by progenitor, and the generated QueryRequest cannot express full_text_search or semantic_search. It implements Default; deserializing JSON into it silently discards unknown fields. Send search requests over HTTP directly as shown in the Rust SDK README until the generated request type covers them.

React Components#

For search UIs, @antfly/components is a React component library with search boxes, facets, result lists, and answer boxes. Add Search and AI Answers to Your Site builds a page with it; the React Antfly reference covers every component.

npm install @antfly/components @antfly/sdk