In short.
This Pydantic AI guide teaches Python developers to generate text embeddings for search and AI assistants, but building and evaluating the surrounding retrieval system remains their responsibility. It explains query and document embeddings, provider configuration, local inference, dimensions, usage metadata and application testing helpers. Provider differences remain significant, cost estimates can be incomplete, and one Bedrock example conflicts with the page's dimension table. No examples were executed; accuracy, speed and operating costs were not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete selected page at [https://pydantic.dev/docs/ai/guides/embeddings/index.md], including provider setup, RAG design, settings, token counting, errors, testing helpers, instrumentation, reranking and custom embedding models. The opening documentation-index and query-parameter notices concern documentation navigation, rather than Embedder runtime requirements. Linked pages are excluded. All outputs remain documentation examples; installation, provider behavior, local inference, retrieval quality and performance were not tested.
The overview
Identity
The resource is the Pydantic AI Embeddings documentation guide at [https://pydantic.dev/docs/ai/guides/embeddings/index.md]. It teaches a feature of a Python library rather than providing a standalone search application.
Its central interface is Embedder, which generates numerical representations of text through hosted embedding APIs or local Sentence Transformers models.
Assessment
The guide offers a practical route from a first embedding request to decisions about chunking, vector storage and retrieval evaluation. Its strongest feature is explaining how query/document roles and model configuration affect an entire search index.
It is useful implementation guidance, but does not establish which model or retrieval design will work best for a particular collection. The sample outputs are documentation examples, not independently observed results.
Users
It suits Python developers building semantic search, retrieval-augmented generation, duplicate detection, clustering or classification features. Retrieval-augmented generation, or RAG, supplies an AI assistant with relevant source text before it answers.
Beginners need familiarity with package installation, credentials and asynchronous Python functions. Experienced developers get provider-specific settings, device selection, custom provider integration and model wrappers.
Capabilities
The page documents OpenAI, Google, Cohere, VoyageAI, AWS Bedrock and local Sentence Transformers integrations, plus OpenAI-compatible services. Separate embed_query() and embed_documents() methods accommodate models that treat search questions and indexed content differently.
EmbeddingResult exposes vectors, input lookup and usage metadata. Further topics include dimension reduction, supported truncation controls, token counting, categorized provider errors, OpenTelemetry instrumentation and custom EmbeddingModel implementations.
For application tests, TestEmbeddingModel supplies deterministic vectors, while ALLOW_MODEL_REQUESTS can block provider requests. These helpers do not measure semantic retrieval quality.
Using it
Requirements
Hosted integrations require the appropriate Python dependencies and provider credentials. The guide supplies optional dependency groups for pydantic-ai-slim; VoyageAI and Sentence Transformers have explicit installation instructions. Bedrock additionally requires AWS credentials and access to the desired models.
Local Sentence Transformers inference requires an initial model download and suitable compute. The guide demonstrates device selection but specifies no minimum Python version, RAM, GPU memory or hardware sizing.
A custom RAG application also needs source preparation, vector storage, retrieval logic and an evaluation dataset. These are separate from generating embeddings.
Mechanism
Embeddings encode text as sequences of numbers intended to capture meaning. A custom retrieval system embeds source documents, stores their vectors and metadata, embeds a search query, then retrieves similar vectors and passes the associated text to an agent.
Indexing and querying must use compatible model configurations. Equal vector lengths alone do not establish compatibility; changing models requires re-embedding documents and updating the index.
Settings merge from model defaults to embedder defaults to individual calls, with later values overriding matching keys. Provider behavior still differs: Google models have distinct task-conditioning mechanisms, while Bedrock Titan and Nova process multiple inputs through individual requests with configurable concurrency.
Setup
For the documented OpenAI route, install pydantic-ai-slim[openai], configure OPENAI_API_KEY and construct Embedder('openai:text-embedding-3-small'). Call its methods from an asynchronous function. The short examples require importing asyncio and adding asyncio.run(main()) to become standalone scripts.
For local inference, install pydantic-ai-slim[sentence-transformers] and choose a sentence-transformers: model identifier. The model downloads on first use. CPU or GPU selection is configurable; practical capacity and throughput are unknown.
Before creating an index, establish the model, query/document behavior, output dimensions and input limits. Preserve source identifiers and permission metadata with stored chunks.
Example
The opening example creates an OpenAI-backed Embedder, embeds the query 'What is machine learning?' and then embeds three short documents about machine learning, neural networks and Python. The documentation shows a 1,536-dimensional query vector and three document embeddings; those outputs were not reproduced.
To turn that example into document search, an application would store the document vectors, search them using the query vector and return their source text. For RAG, it would then provide the retrieved text to an agent. The opening example implements only embedding generation.
Assessment & evidence
Limitations
Pydantic AI does not prescribe a vector database or ship a reranker provider class. Chunking, filtering, permission enforcement, storage operations and retrieval evaluation remain application decisions. The guide supplies no measured accuracy or latency comparison.
Settings and token counting are provider-dependent. Titan does not support truncation, and Bedrock embedding models do not support count_tokens(). The request-blocking test guard leaves local Sentence Transformers inference and local OpenAI tokenization available.
The Bedrock table lists Titan v2 dimensions as 256, 384 or 1,024, but a later example requests 512. This internal inconsistency needs resolution before copying that configuration. Printed token-limit examples likewise do not independently verify current provider limits.
Reasoning
The shared interface is a useful fit when an application needs consistent embedding calls across providers or a choice between hosted and local inference. It does not make embedding spaces interchangeable, so changing a model can still require rebuilding an index.
The guide's emphasis on representative evaluation is justified by the interacting choices it describes: chunk boundaries, model, similarity metric, retrieval count and reranking. A public model ranking alone cannot establish the quality of a complete application pipeline.
Local inference can keep the embedding computation within the application's infrastructure. That does not establish the privacy of separate storage, monitoring or generation services.
Alternatives
For a provider-managed retrieval pipeline, the guide points to FileSearchTool using the ID of a provider-managed store into which files have been uploaded or imported. In that approach, the provider handles chunking, embeddings, storage and retrieval. The guide links to File Search Tool documentation for supported providers. Linked pages and applicable service terms were not assessed.
For custom storage, the page names FAISS, LanceDB, SQLite vector extensions, PostgreSQL with pgvector and managed search services. These serve different infrastructure needs; the page supplies no comparative measurements.
For optional reranking, it demonstrates a local Sentence Transformers CrossEncoder and names hosted Cohere, VoyageAI and Jina alternatives. Their relative accuracy, latency and pricing are unknown.
Evidence
The evidence consists of the complete selected Pydantic AI Embeddings guide at [https://pydantic.dev/docs/ai/guides/embeddings/index.md]. It supports descriptions of documented interfaces, examples and design guidance.
Linked API references, provider documentation, repositories, model cards and leaderboards are outside the assessed scope. No installation, code example, API request, local model or retrieval pipeline was executed. Reliability, performance and example outputs remain unverified.
Access & freshness
Costs
Actual operating costs are unknown. The page provides no provider price schedule, workload estimate or measured infrastructure cost. Local Sentence Transformers avoids embedding API charges, but compute and storage requirements remain.
EmbeddingResult.cost() depends on genai-prices having pricing data for the model. A printed zero estimate does not establish free usage. The guide specifically warns that missing Google token usage can produce a zero estimate, while automatic instrumentation omits a cost estimate for such unmeasured requests.
Chunk overlap increases index size, and optional reranking adds computation or hosted-service usage. Their financial impact is not quantified.
Rights
The selected page does not provide a documentation licence, library licence, redistribution grant or model-specific commercial-use terms. Those permissions are unknown from this evidence.
Hosted-provider terms and downloaded-model licences require separate examination. Public documentation and the ability to run a model locally do not establish permission to redistribute it or use it commercially.
Freshness
The supplied page was captured on 24 November 2026 at 12:19:29.540 UTC. The selected text states no publication date, last-updated date or compatible pydantic-ai package version.
Compatibility with an installed release, current model availability, provider limits and current pricing are therefore unknown. The capture time establishes when this text was retained, not when each technical claim was last validated.
Actions
Choose hosted or local embedding based on data handling, infrastructure and workload needs. Confirm the chosen model's licence, input limits, supported dimensions and query/document behavior, including resolving the Titan dimension inconsistency.
Start with natural document boundaries plus a token limit, retain source and permission metadata, and keep indexing and query configurations compatible. Compare retrieval results using representative questions and documents before committing to a large index.
Use TestEmbeddingModel to check application integration without provider calls, then evaluate semantic retrieval separately. Inspect usage completeness before relying on cost estimates, and assess reranking only when baseline retrieval results justify the added work.
