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.
| Language | Package | Registry | Source |
|---|---|---|---|
| Go | github.com/antflydb/antfly/go/pkg/sdk | pkg.go.dev | GitHub |
| TypeScript | @antfly/sdk | npm | GitHub |
| Python | antfly-sdk | PyPI | GitHub |
| Rust | antfly-sdk | Not yet published; use a git dependency | GitHub |
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:
| Language | Package | Source |
|---|---|---|
| Go | github.com/antflydb/antfly/go/pkg/embedded | go/pkg/embedded |
| Python | antfly-embedded (import antfly_embedded) | py/packages/embedded |
| Rust | antfly-embedded | rs/crates/embedded |
| TypeScript (Node) | @antfly/embedded | ts/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@ddba6584b38b59c62e261ef63e0374dc1f711617npm install /tmp/antfly-sdk-0.2.0.tgz # built from the pinned source abovepip install "antfly-sdk @ git+https://github.com/antflydb/antfly.git@ddba6584b38b59c62e261ef63e0374dc1f711617#subdirectory=py/packages/sdk"# Cargo.toml
[dependencies]
antfly-sdk = { git = "https://github.com/antflydb/antfly", rev = "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")),
)import { AntflyClient } from '@antfly/sdk';
const client = new AntflyClient({
baseUrl: 'http://127.0.0.1:8080',
auth: {
username: 'admin',
password: 'password',
},
});from antfly import AntflyClient
client = AntflyClient(
base_url='http://127.0.0.1:8080',
username='admin',
password='password',
)// Cargo.toml also needs: base64 = "0.22"
use antfly_sdk::new_client;
use base64::Engine as _;
use reqwest::header::{AUTHORIZATION, HeaderMap, HeaderValue};
let encoded = base64::engine::general_purpose::STANDARD.encode("admin:password");
let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("Basic {encoded}"))?,
);
let client = new_client(
"http://127.0.0.1:8080",
reqwest::Client::builder().default_headers(headers).build()?,
);API Key
client, err := antfly.NewAntflyClientWithOptions(
"http://127.0.0.1:8080",
oapi.WithRequestEditorFn(antfly.WithApiKey("key-id", "key-secret")),
)const client = new AntflyClient({
baseUrl: 'http://127.0.0.1:8080',
auth: {
type: 'apiKey',
keyId: 'key-id',
keySecret: 'key-secret',
},
});client = AntflyClient(
base_url='http://127.0.0.1:8080',
api_key=('key-id', 'key-secret'),
)// Cargo.toml also needs: base64 = "0.22"
use antfly_sdk::new_client;
use base64::Engine as _;
use reqwest::header::{AUTHORIZATION, HeaderMap, HeaderValue};
let encoded = base64::engine::general_purpose::STANDARD.encode("key-id:key-secret");
let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("ApiKey {encoded}"))?,
);
let client = new_client(
"http://127.0.0.1:8080",
reqwest::Client::builder().default_headers(headers).build()?,
);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")),
)const client = new AntflyClient({
baseUrl: 'http://127.0.0.1:8080',
auth: {
type: 'token',
token: 'your-token',
},
});client = AntflyClient(
base_url='http://127.0.0.1:8080',
token='your-token',
)use antfly_sdk::new_client_with_token;
let client = new_client_with_token("http://127.0.0.1:8080", "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,
},
},
})import { AntflyClient } from '@antfly/sdk';
const client = new AntflyClient({
baseUrl: 'http://127.0.0.1:8080',
auth: { username: 'admin', password: 'password' },
});
// Batch insert documents
await client.tables.batch('products', {
inserts: {
'prod:001': { name: 'Laptop', price: 1299.99 },
'prod:002': { name: 'Mouse', price: 29.99 },
},
});from antfly import AntflyClient
client = AntflyClient(
base_url='http://127.0.0.1:8080',
username='admin',
password='password',
)
# Batch insert documents
client.batch(
table='products',
inserts={
'prod:001': {'name': 'Laptop', 'price': 1299.99},
'prod:002': {'name': 'Mouse', 'price': 29.99},
},
)use antfly_sdk::new_client;
use antfly_sdk::types::BatchRequest;
use serde_json::json;
use std::collections::HashMap;
let client = new_client("http://127.0.0.1:8080", reqwest::Client::new());
// Batch insert documents. Each value is a JSON object.
let mut inserts = HashMap::new();
inserts.insert(
"prod:001".to_string(),
json!({"name": "Laptop", "price": 1299.99}).as_object().unwrap().clone(),
);
inserts.insert(
"prod:002".to_string(),
json!({"name": "Mouse", "price": 29.99}).as_object().unwrap().clone(),
);
client
.batch_write(
"products",
&BatchRequest {
inserts,
..Default::default()
},
)
.await?;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)
}const results = await client.query({
table: 'products',
full_text_search: { query: 'laptop' },
limit: 10,
});
for (const hit of results?.hits?.hits ?? []) {
console.log(hit._id, hit._source);
}results = client.query(
table='products',
full_text_search={'query': 'laptop'},
limit=10,
)
for hit in results.responses[0].hits.hits:
print(hit.field_id, hit.field_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