Skip to main content

Documentation Index

Fetch the complete documentation index at: https://hastekit.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

HasteKit SDK supports generating text embeddings with various LLM providers like OpenAI and Gemini.

Generate embeddings

Generate embeddings for a single text input.
resp, err := client.NewEmbedding(context.Background(), &embeddings.Request{
    Model: "Gemini/models/gemini-embedding-001",
    Input: embeddings.InputUnion{
        OfString: utils.Ptr("The food was delicious and the waiter..."),
    },
})
if err != nil {
    log.Fatal(err)
}

Response

The response contains an array of embedding data. Each embedding is a vector of floats (or base64 encoded string).
for _, data := range resp.Data {
    // Access float embeddings
    if data.Embedding.OfFloat != nil {
        fmt.Println("Embedding vector:", data.Embedding.OfFloat)
        fmt.Println("Dimensions:", len(data.Embedding.OfFloat))
    }
    
    // Access base64 encoded embeddings
    if data.Embedding.OfBase64 != nil {
        fmt.Println("Base64 embedding:", *data.Embedding.OfBase64)
    }
}

// Access usage information
if resp.Usage != nil {
    fmt.Println("Prompt tokens:", resp.Usage.PromptTokens)
    fmt.Println("Total tokens:", resp.Usage.TotalTokens)
}

Batch Embeddings

Generate embeddings for multiple texts in a single request.
resp, err := client.NewEmbedding(context.Background(), &embeddings.Request{
    Model: "Gemini/models/gemini-embedding-001",
    Input: embeddings.InputUnion{
        OfList: []string{
            "The food was delicious",
            "The service was excellent",
            "Great atmosphere",
        },
    },
})
if err != nil {
    log.Fatal(err)
}

// Each input text gets its own embedding at the corresponding index
for _, data := range resp.Data {
    fmt.Printf("Index %d: %d dimensions\n", data.Index, len(data.Embedding.OfFloat))
}

Request Configuration

ParameterTypeDescription
InputInputUnionThe text input (single string or list of strings).
Dimensions*intNumber of dimensions for the output embeddings.
EncodingFormat*stringFormat for embeddings: "float" or "base64".

Response Structure

FieldTypeDescription
ObjectstringObject type identifier.
ModelstringThe model used for generating embeddings.
Data[]EmbeddingDataArray of embedding results.
Usage*UsageToken usage statistics.

EmbeddingData

FieldTypeDescription
IndexintIndex of the input text this embedding corresponds to.
EmbeddingEmbeddingDataUnionThe embedding vector (float array or base64 string).

Supported Providers

ProviderEmbeddings
OpenAI
Gemini
Anthropic