SDKs
Antfly Inference is available through the unified Antfly SDKs for Go and TypeScript. Antfly Inference also exposes an Ollama-compatible /ai/v1/embed endpoint, so any Ollama client library works for embedding generation.
| Language | Package | Registry | Source |
|---|---|---|---|
| Go | github.com/antflydb/antfly/go/pkg/sdk | pkg.go.dev | GitHub |
| TypeScript | @antfly/sdk | npm | GitHub |
Installation
go get github.com/antflydb/antfly/go/pkg/sdknpm install @antfly/sdkQuick Start
Generate Embeddings
import (
"context"
"net/http"
"github.com/antflydb/antfly/go/pkg/sdk"
)
c, err := sdk.NewAntfly InferenceClient("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 { Antfly InferenceClient } from '@antfly/sdk';
const client = new Antfly InferenceClient({
baseUrl: 'http://localhost:8080',
});
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 Antfly Inference HTTP API directly for chunking
import "net/http"
req, _ := http.NewRequest("POST", "http://localhost:8080/ai/v1/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 Antfly Inference HTTP API directly for reranking
import "net/http"
req, _ := http.NewRequest("POST", "http://localhost:8080/ai/v1/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
Antfly Inference implements the Ollama /ai/v1/embed endpoint, so any Ollama client library can generate embeddings from Antfly Inference. This is useful if you already use Ollama in your stack and want to swap in Antfly Inference for ONNX-based inference.
# Works with the Ollama API format
curl -X POST http://localhost:8080/ai/v1/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.