Overview
Morph provides an OpenAI-compatible API for generating embeddings from code and text. State of the art on code retrieval tasks with our latestmorph-embedding-v3
model.
Example Request
Model Selection
We recommend usingmorph-embedding-v3
for the best performance on code retrieval tasks. This model offers:
- State-of-the-Art Performance: Achieves SoTA results across all coding benchmarks for accuracy:speed ratio
- 1024 Dimensions: Optimal dimensionality for rich semantic representation while maintaining efficiency
- Unmatched Speed: Fastest inference in the market - no embedding model comes close on accuracy:speed
- Enhanced Context: Superior handling of longer code snippets and complex codebases
morph-embedding-v3
remains available.
Input Format
The request accepts the following parameters:Parameter | Type | Required | Description |
---|---|---|---|
model | string | Yes | The model ID to use for embedding generation. Use morph-embedding-v3 (latest) or morph-embedding-v3 . |
input | string or array | Yes | The text to generate embeddings for. Can be a string or an array of strings. |
encoding_format | string | No | The format in which the embeddings are returned. Options are float and base64 . Default is float . |
Batch Processing Example
Response Format
Usage with Vector Databases
Embeddings can be stored in vector databases for efficient similarity searching:Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
Embedding generation request
ID of the model to use for embedding generation
Example:
"morph-embedding-v3"
The text to generate embeddings for
Example:
"function calculateSum(a, b) { return a + b; }"
The format in which the embeddings are returned
Available options:
float
, base64