OpenAIEmbeddingProvider

org.llm4s.llmconnect.provider.OpenAIEmbeddingProvider

OpenAI embedding provider implementation.

Provides text embeddings using OpenAI's embedding API (text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002). Supports batch embedding of multiple texts in a single request.

== Supported Models ==

  • text-embedding-3-small - Efficient, lower cost (recommended)
  • text-embedding-3-large - Higher quality, higher cost
  • text-embedding-ada-002 - Legacy model

== Token Usage == The response includes token usage information when available from the API.

OpenAI's entry in the embedding half of the provider SPI.

The object that builds the provider is also its org.llm4s.llmconnect.spi.EmbeddingProviderDescriptor, so there is one place per provider rather than a descriptor shadowing a factory.

Attributes

See also

EmbeddingProvider for the provider interface

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Builds the provider for the SPI; see fromConfig for the direct route.

Builds the provider for the SPI; see fromConfig for the direct route.

Attributes

Creates an OpenAI embedding provider from configuration.

Creates an OpenAI embedding provider from configuration.

Value parameters

cfg

embedding provider configuration with API key and base URL

Attributes

Returns

configured EmbeddingProvider instance

Inherited methods

def aliases: Set[String]

Alternative spellings accepted in EMBEDDING_MODEL=<name>/<model>, folded onto id.

Alternative spellings accepted in EMBEDDING_MODEL=<name>/<model>, folded onto id.

Attributes

Inherited from:
EmbeddingProviderDescriptor

Concrete fields

val id: ProviderId

Canonical id, e.g. ProviderId("voyage"). Must be unique among the embedding providers in a registry.

Canonical id, e.g. ProviderId("voyage"). Must be unique among the embedding providers in a registry.

Chat and embedding ids live in separate namespaces, so a provider that supplies both — OpenAI, Ollama — uses the same id for each without a clash. That is what lets EMBEDDING_MODEL=ollama/nomic-embed-text and LLM_MODEL=ollama/llama3 name the same provider.

Attributes