Share via


OpenAITextEmbedding Class

OpenAI Text Embedding class.

Note: This class is marked as 'experimental' and may change in the future.

Initializes a new instance of the OpenAITextCompletion class.

Constructor

OpenAITextEmbedding(ai_model_id: str | None = None, api_key: str | None = None, org_id: str | None = None, service_id: str | None = None, default_headers: Mapping[str, str] | None = None, async_client: AsyncOpenAI | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None)

Parameters

Name Description
ai_model_id
str
Default value: None
service_id
<xref:<xref:semantic_kernel.connectors.ai.open_ai.str | None>>

Service ID tied to the execution settings.

Default value: None
api_key
<xref:<xref:semantic_kernel.connectors.ai.open_ai.str | None>>

The optional API key to use. If provided will override, the env vars or .env file value.

Default value: None
org_id
<xref:<xref:semantic_kernel.connectors.ai.open_ai.str | None>>

The optional org ID to use. If provided will override, the env vars or .env file value.

Default value: None
default_headers
<xref:Mapping>[str,str]<xref: | None>

The default headers mapping of string keys to string values for HTTP requests. (Optional)

Default value: None
async_client
<xref:Optional>[<xref:AsyncOpenAI>]

An existing client to use. (Optional)

Default value: None
env_file_path
<xref:<xref:semantic_kernel.connectors.ai.open_ai.str | None>>

Use the environment settings file as a fallback to environment variables. (Optional)

Default value: None
env_file_encoding
<xref:<xref:semantic_kernel.connectors.ai.open_ai.str | None>>

The encoding of the environment settings file. (Optional)

Default value: None

Methods

from_dict

Initialize an Open AI service from a dictionary of settings.

from_dict

Initialize an Open AI service from a dictionary of settings.

from_dict(settings: dict[str, Any]) -> T_

Parameters

Name Description
settings
Required

A dictionary of settings for the service.

Attributes

ai_model_type

ai_model_type: OpenAIModelTypes

client

client: AsyncOpenAI

completion_tokens

completion_tokens: int

is_experimental

is_experimental = True

prompt_tokens

prompt_tokens: int

stage_status

stage_status = 'experimental'

total_tokens

total_tokens: int