> ## 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.

# Embeddings

> Generate vectors for one string or a batch and retain their model identity.

Call `NewEmbedding` on a model bound to an embedding-capable provider. Import `github.com/hastekit/agent-sdk-go/pkg/gateway/llm/embeddings`.

Given `client` and `ctx`:

```go theme={null}
model := client.Model("OpenAI/text-embedding-3-small")
response, err := model.NewEmbedding(ctx, &embeddings.Request{
    Input: embeddings.InputUnion{OfList: []string{"First document", "Second document"}},
})
if err != nil { return err }
for _, item := range response.Data {
    fmt.Println(item.Index, len(item.Embedding.OfFloat))
}
```

For one string, use `Input.OfString`. Set only one input-union branch. Use each response entry's `Index` to associate vectors with inputs.

## Dimensions and encoding

`Dimensions` requests a dimension count where the model supports it. `EncodingFormat` can request floating-point values or base64 where supported. Inspect `Embedding.OfFloat` or `Embedding.OfBase64` accordingly; do not treat an empty float slice as proof of an empty embedding.

Store model identity, dimensions, and preprocessing choices with an index. Query vectors must be compatible with the document vectors. Changing models or dimensions generally requires rebuilding the affected index rather than mixing vectors.

## Batching and limits

Batch within provider input and request-size limits, and handle per-request failures before writing index entries. The SDK does not automatically chunk documents, choose a vector database, or manage your retrieval policy. Usage is available when the provider reports it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.