Skip to main content

Prerequisites

Install the Tracia SDK:
Set your API keys as environment variables:
.env
The Python SDK uses LiteLLM under the hood. LiteLLM is included as a dependency and handles all provider communication.

Single Text Embedding

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

Batch Embedding

Pass a list 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 trace_id and parent_span_id 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:

Async Usage

Use arun_embedding() for async contexts:
Batch embedding works the same way in async:

Google Embeddings

Amazon Bedrock Embeddings

RunEmbeddingInput Reference

RunEmbeddingResult Reference

EmbeddingVector

EmbeddingUsage