Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / Config

embedding provider (app.Embedding)

app.Embedding = new EmbeddingConfig { Provider = EmbeddingProvider.OpenAI, Model = "…", ApiKey = Secret.X, Dimensions = N };

`app.Embedding` declares the embedding model the app uses to turn text into vectors for semantic search over `[Searchable]` fields (see `Memory.Search`). You name a `Provider`, a `Model` string, the `ApiKey` (a `Secret.X` handle), and the vector `Dimensions`. A singleton.

stable1 example compiled by CIconfigembeddingvectorsearch

Summary#

app.Embedding declares the embedding model your application uses to turn text into vectors, so that semantic search over [Searchable] fields (queried through Memory.Search) has something to embed against. You name a provider, a model, the secret that authenticates to that provider, and the dimensions of the vectors it returns. It is a singleton — one embedding configuration per app.

app.Embedding = new EmbeddingConfig {
  Provider   = EmbeddingProvider.OpenAI,
  Model      = "text-embedding-3-small",
  ApiKey     = Secret.OpenAI,
  Dimensions = 1536,
};

Signature#

app.Secrets = [ new Secret("OpenAI") ];   // the handle the config below reads

app.Embedding = new EmbeddingConfig {
  Provider   = EmbeddingProvider.OpenAI,   // which embedding provider
  Model      = "text-embedding-3-small",   // the provider's embedding model id
  ApiKey     = Secret.OpenAI,              // a Secret.X handle from app.Secrets
  Dimensions = 1536,                       // the width of the produced vectors
};

app.Embedding is a single value, not a list — an app configures exactly one embedding model.

Description#

An EmbeddingConfig has four members:

  • Provider — an EmbeddingProvider enum member naming which service produces the vectors. The example uses EmbeddingProvider.OpenAI.
  • Model — the provider's embedding model id, as a string (for example "text-embedding-3-small"). This chooses which model the provider runs.
  • ApiKey — a Secret.X handle referencing a secret declared in app.Secrets. It authenticates calls to the provider; the value itself lives outside your source.
  • Dimensions — the width of each produced vector (for example 1536). This must match the vector size the chosen model emits, so that stored [Searchable] vectors and query vectors are comparable.

app.Embedding is a singleton: an application declares one embedding configuration, and every [Searchable] field and every Memory.Search query uses it.

Examples#

Declare the secret, then configure OpenAI embeddings against it:

app.Secrets = [ new Secret("OpenAI") ];

app.Embedding = new EmbeddingConfig {
  Provider = EmbeddingProvider.OpenAI,
  Model = "text-embedding-3-small",
  ApiKey = Secret.OpenAI,
  Dimensions = 1536,
};

See also#

Related

declaring secrets (app.Secrets)

`app.Secrets` declares the named secrets your app uses — API keys, tokens, client secrets. Each is `new…

[Searchable]

Mark a text field searchable. `[Searchable]` gives a String or Markdown property the best relevance search the app can…

using Memory (semantic search)

Opt into semantic (vector) search over your app's content. `using Memory;` adds a searchable store to the app…