Skip to main content

Prerequisites

Install the Tracia SDK and the provider package(s) you need:
Set your API keys as environment variables:
.env

Single Text Embedding

Pass a string to input to embed a single piece of text:

Batch Embedding

Pass an array of strings to embed multiple texts in a single request:
Batch embedding is more efficient than making separate requests for each text. The provider processes all inputs in a single API call.

Specifying Dimensions

Some models support reducing the embedding dimensions. This is useful for saving storage space or improving retrieval speed:
Not all models support the dimensions parameter. Currently, OpenAI’s text-embedding-3-small and text-embedding-3-large, and Google’s text-embedding-004 support it.

Using with Sessions

Sessions automatically chain embedding spans with other spans under the same trace:
The session manages traceId and parentSpanId automatically, so all spans appear in sequence in the Tracia dashboard.

With Tracing Metadata

Add tags and user identifiers for filtering in the Tracia dashboard:

Without Tracing

Disable tracing when you don’t need observability:

Google Embeddings

Amazon Bedrock Embeddings

RunEmbeddingInput Reference

RunEmbeddingResult Reference

EmbeddingVector

EmbeddingUsage