engine-embeddings
Create engine embeddings
Section titled “Create engine embeddings”Create embedding vectors for input text using specified engine
Request
Section titled “Request”POST /engines/{model}/embeddingsPath Parameters
Section titled “Path Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Engine model name |
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | Input text to embed, encoded as a string or array of tokens. |
| encoding_format | string (float, base64) | No | The format to return the embeddings in. Can be either “float” or “base64”. |
| dimensions | integer | No | The number of dimensions the resulting output embeddings should have. |
| user | string | No | A unique identifier representing your end-user. |
Request Examples
Section titled “Request Examples”Create embedding using engine
Section titled “Create embedding using engine”{ "input": "The quick brown fox jumps over the lazy dog"}Batch create embeddings
Section titled “Batch create embeddings”{ "input": [ "First text", "Second text" ], "encoding_format": "float"}Specify dimensions and encoding format
Section titled “Specify dimensions and encoding format”{ "input": [ "Customer feedback: great service!" ], "encoding_format": "base64", "dimensions": 512}Successful response
Response Schema
Section titled “Response Schema”| Field | Type | Required | Description |
|---|---|---|---|
| object | string | Yes | The object type, which is always “list”. |
| data | Array<EmbeddingObject> | Yes | The list of embeddings generated by the model. |
| model | string | Yes | The name of the model used to generate the embedding. |
| usage | object | Yes | The usage information for the request. |
Code Examples
Section titled “Code Examples”JavaScript (Fetch)
Section titled “JavaScript (Fetch)”const response = await fetch('https://api.r9s.ai/v1/engines/{model}/embeddings', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ "input": "The quick brown fox jumps over the lazy dog"})});
const data = await response.json();console.log(data);Python (requests)
Section titled “Python (requests)”import requests
url = "https://api.r9s.ai/v1/engines/{model}/embeddings"headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
response = requests.post(url, json={ "input": "The quick brown fox jumps over the lazy dog"}, headers=headers)data = response.json()print(data)curl -X POST "https://api.r9s.ai/v1/engines/{model}/embeddings" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"input":"The quick brown fox jumps over the lazy dog"}'Schema Reference
Section titled “Schema Reference”EngineEmbeddingRequest
Section titled “EngineEmbeddingRequest”| Field | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | Input text to embed, encoded as a string or array of tokens. |
| encoding_format | string (float, base64) | No | The format to return the embeddings in. Can be either “float” or “base64”. |
| dimensions | integer | No | The number of dimensions the resulting output embeddings should have. |
| user | string | No | A unique identifier representing your end-user. |
EmbeddingResponse
Section titled “EmbeddingResponse”| Field | Type | Required | Description |
|---|---|---|---|
| object | string | Yes | The object type, which is always “list”. |
| data | Array<EmbeddingObject> | Yes | The list of embeddings generated by the model. |
| model | string | Yes | The name of the model used to generate the embedding. |
| usage | object | Yes | The usage information for the request. |
EmbeddingObject
Section titled “EmbeddingObject”| Field | Type | Required | Description |
|---|---|---|---|
| object | string | Yes | The object type, which is always “embedding”. |
| embedding | Array | Yes | The embedding vector, which is a list of floats. The length of vector depends on the model. |
| index | integer | Yes | The index of the embedding in the list of embeddings. |
Related APIs
Section titled “Related APIs”- API Overview - Learn about authentication and basic information
- models - View models related APIs
- chat - View chat related APIs
- responses - View responses related APIs
- messages - View messages related APIs
- completions - View completions related APIs
- edits - View edits related APIs
- images - View images related APIs
- embeddings - View embeddings related APIs
- moderations - View moderations related APIs
- audio - View audio related APIs
- search - View search related APIs
- proxy - View proxy related APIs