Embeddings
Generate vector embeddings for text
The Embeddings API enables you to generate numerical representations of text that can be used for semantic search, clustering, and other machine learning tasks.
Create Embeddings
POST /embeddings
Generate embeddings for input text.
Request Body
Input text to embed, encoded as a string or array of strings
The model to use for generating embeddings (e.g., “text-embedding-ada-002”, “text-embedding-3-small”, “text-embedding-3-large”)
The format to return the embeddings in (“float” or “base64”)
The number of dimensions the resulting output embeddings should have (only supported in text-embedding-3 models)
A unique identifier representing your end-user
Response
Returns an embedding object containing the vector embeddings.
Example
Multiple Inputs
You can embed multiple text inputs in a single request:
Use Cases
- Semantic Search: Find documents similar to a query
- Clustering: Group similar texts together
- Classification: Train classifiers on embedding features
- Recommendation: Recommend items based on similarity
- Anomaly Detection: Identify outliers in text data
Best Practices
- Use
text-embedding-3-small
for most use cases (good balance of performance and cost) - Use
text-embedding-3-large
for maximum performance - Batch multiple inputs in a single request for efficiency
- Store embeddings for reuse rather than regenerating them
Authorizations
Enter your API key (starts with 'ek-')
Body
Response
Success
The response is of type object
.