Whatever message this page gives is out now! Go check it out!

EmbeddingModel

Last update:
May 18, 2026

Description

Initializes a new Embedding Model client instance. This function acts as the factory for connecting to various embedding providers (such as OpenAI, Azure OpenAI, local models, etc.). It encapsulates model configuration (model name, dimension, provider) and connection settings.

Syntax

EmbeddingModel(struct configuration)

Returns

An EmbeddingModel object used to generate embeddings for text input.

Parameters

Parameter
Type
Required
Description
configuration
Struct
Yes
Structure containing provider and model configuration.
Configuration struct details
The configuration structure supports the following common keys. Exact support varies by provider (OpenAI, AzureOpenAI, local, etc.).
Provider parameters
Provider
Required
Optional
OpenAI
API Key Model Name
Base URL Dimension Organization ID Project ID User Batch Size Max Retries Timeout (ms) Log Requests Log Responses
Azure OpenAI
API Key Deployment Name
Base URL Dimension Max Retries Timeout (ms) Log Requests Log Responses
Mistral
API Key Model Name
Base URL Max Retries Timeout (ms) Log Requests Log Responses
Ollama
Model Name
Base URL Max Retries Timeout (ms) Log Requests Log Responses
Gemini
API Key Model Name
Base URL Dimension Max Retries Timeout (ms) Log Requests Log Responses
Key
Type
Default
Description
provider
String
-
Embedding provider. Examples: "openai", "azureOpenAI", "ollama".
apiKey
String
-
API key or token for the provider (if required).
baseUrl
String
-
Optional base endpoint URL (for self‑hosted or Azure endpoints).
modelName
String
-
Embedding model identifier. Example: "text-embedding-3-small".
dimension
Numeric
-
Expected embedding dimension (for validation).
timeout
Numeric
10000
Request timeout in milliseconds.
maxRetries
Numeric
2
Maximum retry attempts for transient failures.
logRequests
Boolean
true
Whether to log outbound requests (for debugging).
logResponses
Boolean
true
Whether to log responses (for debugging).
metadata
Struct
{}
Optional key‑value metadata to tag embedding calls.

Usage

Use EmbeddingModel once during initialization. The returned embeddingModel instance exposes: embed(text) – generate an embedding for a single text string.
  • embedAll(textArray) – generate embeddings for an array of text strings.
The model configuration (provider, model name, dimension) is fixed per instance.

Example

<cfscript>
    embeddingModelConfig = EmbeddingModel(
        {
            provider : "openAI",
            modelName : "text-embedding-3-small",
            apiKey : "#application.apiKey#"
        }
    )
    
    //embeddingModelConfig.embed("The quick brown fox jumps over the lazy dog")
    //writeDump(response)

    // add a vector store
    inMemoryClient=VectorStore({
        provider:"inMemory"
    });
    // add a single item to vector store
    response=inMemoryClient.add({
        id: createUUID(),
        embedding: embeddingModelConfig,
        text: "ColdFusion is a powerful rapid application development platform",
        metadata: {"category": "technology", "test": "add"}
    })
    writeDump(response)
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page