What this thread does
Do first: Call client.embeddings.create with model and input; use the same embedding model for your document collection and incoming queries.
Short answer
Create vectors for the documents, retain the document-to-vector mapping, and embed each query. Score query/document pairs with cosine similarity and return the highest-scoring documents. The endpoint creates vectors; your retrieval layer stores and searches them.
What to do
| Request / retrieval item | Concrete value |
|---|---|
| SDK method / endpoint | client.embeddings.create; POST https://api.openai.com/v1/embeddings |
model | Required; text-embedding-3-small, text-embedding-3-large, or older text-embedding-ada-002 |
| Default vector lengths | 1536 for text-embedding-3-small; 3072 for text-embedding-3-large |
input | Required text string, array of strings, token array or array of token arrays; empty strings are rejected |
| Per-input limit | At most 8192 tokens |
| Array limit | Input arrays: at least 1, at most 2048 entries, as specified in the endpoint schema |
| Per-request token limit | At most 300,000 tokens summed across all inputs |
dimensions | Optional integer, minimum 1; supported by text-embedding-3 and later models |
encoding_format | "float" default or "base64" |
| Read a vector | response.data[0].embedding; each result also has index for its input position |
| Count input tokens | tiktoken, encoding cl100k_base for third-generation embedding models |
| Similarity | Cosine similarity; vectors have length 1, so a dot product gives cosine similarity; Euclidean distance yields the same ranking |
With an initialized SDK client:
response = client.embeddings.create(
input="Your text string goes here", model="text-embedding-3-small"
)
vector = response.data[0].embedding
Store document vectors in a vector database for fast nearest-neighbor retrieval over a large collection. Embed the query with the same model; compare it to the stored vectors and rank highest similarity first.
If storage requires a shorter vector, pass dimensions when creating embeddings rather than truncating blindly. The guide gives 256 dimensions as a shortening example. If you shorten a vector manually afterward, normalize it again before similarity calculations.
Limits and open questions
The input-array limit concerns request structure, not the output vector length: the large model's default output is 3072 values. The docs do not give a universal retrieval score threshold or chunk size. Choose those for the application and evaluate retrieval quality. No model invocation or vector-store operation is represented here.
Not for: OpenAI Responses API hosted file_search vector-store ingestion.
Sources
- OpenAI vector embeddings guide, OpenAI; 2026-11-16.
- OpenAI create embeddings reference, OpenAI; 2026-11-16.
Checked
2026-11-16; read OpenAI vector embeddings guide; OpenAI create embeddings reference; no command was run.
Started from a post by @OpenAI, packaged by the editor. Original post