Implementation:Openai Openai python Embedding Create Params
Appearance
| Knowledge Sources | |
|---|---|
| Domains | NLP, Embeddings |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete TypedDict parameter type for configuring embedding generation requests provided by the OpenAI Python SDK.
Description
EmbeddingCreateParams defines the valid input format for embedding requests. It accepts text strings, string lists, token integer arrays, or batches of token arrays. The model parameter selects the embedding model, and optional dimensions parameter enables output truncation for newer models.
Usage
Parameters are passed as keyword arguments to client.embeddings.create().
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/embedding_create_params.py
- Lines: L1-55
Signature
class EmbeddingCreateParams(TypedDict, total=False):
input: Required[Union[str, List[str], Iterable[int], Iterable[Iterable[int]]]]
model: Required[Union[str, EmbeddingModel]]
dimensions: int
encoding_format: Literal["float", "base64"]
user: str
Import
from openai.types import EmbeddingCreateParams
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| input | str, list[str], Iterable[int], Iterable[Iterable[int]] | Yes | Text or token input |
| model | str | Yes | Embedding model ID |
| dimensions | int | No | Output vector dimensions (text-embedding-3-* only) |
| encoding_format | str | No | "float" or "base64" |
Outputs
| Name | Type | Description |
|---|---|---|
| params | TypedDict | Configuration for embeddings.create() |
Usage Examples
Single Text
from openai import OpenAI
client = OpenAI()
response = client.embeddings.create(
input="The quick brown fox",
model="text-embedding-3-small",
)
Batch Text
response = client.embeddings.create(
input=["Text one", "Text two", "Text three"],
model="text-embedding-3-small",
)
With Dimension Truncation
response = client.embeddings.create(
input="Some text to embed",
model="text-embedding-3-large",
dimensions=256, # Truncate from 3072 to 256 dimensions
)
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment