> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.privategpt.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server.

# Generate embeddings for text input

POST /v1/embeddings
Content-Type: application/json

Generate vector embeddings from input text.

This endpoint converts text into high-dimensional vector representations
that capture semantic meaning. These embeddings preserve semantic
relationships between texts and can be used for various machine learning
tasks.

Notes:
* Empty strings or arrays are not accepted
* Results include index numbers for mapping back to original inputs
* All embeddings are generated as query vectors. If the embeddings have two modes
(e.g., query and document), this endpoint only returns query vectors.

Reference: https://docs.privategpt.dev/api-reference/embeddings/generation-v-1-embeddings-post

## Request

### Body (application/json)

This endpoint expects an EmbeddingsBody.

- `input` (EmbeddingsBodyInput, required) — The text(s) to generate embeddings for. Can be a single string or an array of strings. Each text should be a meaningful unit of text (sentence, paragraph, etc).
- `model` (string, optional, default: default) — Model identifier or alias.

## Response

### 200

Successfully generated embeddings

- `data` (list of Embedding, required) — List of embeddings, one for each input text
- `object` ("list", optional, default: list) — The type of object returned
- `model` ("private-gpt", optional, default: private-gpt) — The model used to generate embeddings

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 422 Unprocessable Entity Error

Validation Error - Invalid input format

- `detail` (OpenApiValidationErrorResponseDetail, required) — Error detail — a string message or a list of validation error objects.

## Types

### EmbeddingsBodyInput

The text(s) to generate embeddings for. Can be a single string or an array of strings. Each text should be a meaningful unit of text (sentence, paragraph, etc).

### Embedding

Represents a vector embedding for a piece of text content.

- `index` (integer, required) — Sequential index of this embedding in the batch, starting from 0
- `embedding` (list of double, required) — High-dimensional vector representation of the text content as a list of floating-point numbers
- `object` ("embedding", optional, default: embedding) — Type identifier for this object, always 'embedding'

### OpenApiValidationErrorResponseDetail

Error detail — a string message or a list of validation error objects.

## Examples

### Embedding for single text input

**Request**

```json
{
  "input": "The quick brown fox jumps over the lazy dog"
}
```

**Response**

```json
{
  "data": [
    {
      "index": 0,
      "embedding": [
        0.123,
        -0.456,
        0.789,
        0.234,
        -0.567,
        0.891,
        -0.123,
        0.445,
        -0.678,
        0.901
      ],
      "object": "embedding"
    }
  ],
  "object": "list",
  "model": "private-gpt"
}
```

**SDK Code**

```python Embedding for single text input
import requests

url = "https://api.example.com/v1/embeddings"

payload = { "input": "The quick brown fox jumps over the lazy dog" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Embedding for single text input
const url = 'https://api.example.com/v1/embeddings';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":"The quick brown fox jumps over the lazy dog"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Embedding for single text input
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/embeddings"

	payload := strings.NewReader("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Embedding for single text input
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/embeddings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}"

response = http.request(request)
puts response.read_body
```

```java Embedding for single text input
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/embeddings")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")
  .asString();
```

```php Embedding for single text input
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/embeddings', [
  'body' => '{
  "input": "The quick brown fox jumps over the lazy dog"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Embedding for single text input
using RestSharp;

var client = new RestClient("https://api.example.com/v1/embeddings");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Embedding for single text input
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["input": "The quick brown fox jumps over the lazy dog"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/embeddings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Embeddings for multiple text inputs

**Request**

```json
{
  "input": "The quick brown fox jumps over the lazy dog"
}
```

**Response**

```json
{
  "data": [
    {
      "index": 0,
      "embedding": [
        0.234,
        -0.567,
        0.123,
        0.678,
        -0.234,
        0.456,
        -0.789,
        0.345,
        -0.123,
        0.567
      ],
      "object": "embedding"
    },
    {
      "index": 1,
      "embedding": [
        -0.123,
        0.456,
        -0.789,
        0.234,
        0.567,
        -0.345,
        0.678,
        -0.234,
        0.789,
        -0.456
      ],
      "object": "embedding"
    },
    {
      "index": 2,
      "embedding": [
        0.567,
        -0.234,
        0.789,
        -0.456,
        0.123,
        0.678,
        -0.345,
        0.234,
        -0.567,
        0.891
      ],
      "object": "embedding"
    }
  ],
  "object": "list",
  "model": "private-gpt"
}
```

**SDK Code**

```python Embeddings for multiple text inputs
import requests

url = "https://api.example.com/v1/embeddings"

payload = { "input": "The quick brown fox jumps over the lazy dog" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Embeddings for multiple text inputs
const url = 'https://api.example.com/v1/embeddings';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":"The quick brown fox jumps over the lazy dog"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Embeddings for multiple text inputs
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/embeddings"

	payload := strings.NewReader("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Embeddings for multiple text inputs
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/embeddings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}"

response = http.request(request)
puts response.read_body
```

```java Embeddings for multiple text inputs
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/embeddings")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")
  .asString();
```

```php Embeddings for multiple text inputs
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/embeddings', [
  'body' => '{
  "input": "The quick brown fox jumps over the lazy dog"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Embeddings for multiple text inputs
using RestSharp;

var client = new RestClient("https://api.example.com/v1/embeddings");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Embeddings for multiple text inputs
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["input": "The quick brown fox jumps over the lazy dog"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/embeddings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Embeddings for semantic similarity comparison

**Request**

```json
{
  "input": "The quick brown fox jumps over the lazy dog"
}
```

**Response**

```json
{
  "data": [
    {
      "index": 0,
      "embedding": [
        0.445,
        0.223,
        -0.667,
        0.112,
        0.889,
        -0.334,
        0.556,
        -0.778,
        0.223,
        0.445
      ],
      "object": "embedding"
    },
    {
      "index": 1,
      "embedding": [
        0.434,
        0.234,
        -0.656,
        0.123,
        0.878,
        -0.345,
        0.567,
        -0.789,
        0.234,
        0.456
      ],
      "object": "embedding"
    }
  ],
  "object": "list",
  "model": "private-gpt"
}
```

**SDK Code**

```python Embeddings for semantic similarity comparison
import requests

url = "https://api.example.com/v1/embeddings"

payload = { "input": "The quick brown fox jumps over the lazy dog" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Embeddings for semantic similarity comparison
const url = 'https://api.example.com/v1/embeddings';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":"The quick brown fox jumps over the lazy dog"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Embeddings for semantic similarity comparison
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/embeddings"

	payload := strings.NewReader("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Embeddings for semantic similarity comparison
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/embeddings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}"

response = http.request(request)
puts response.read_body
```

```java Embeddings for semantic similarity comparison
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/embeddings")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}")
  .asString();
```

```php Embeddings for semantic similarity comparison
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/embeddings', [
  'body' => '{
  "input": "The quick brown fox jumps over the lazy dog"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Embeddings for semantic similarity comparison
using RestSharp;

var client = new RestClient("https://api.example.com/v1/embeddings");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"The quick brown fox jumps over the lazy dog\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Embeddings for semantic similarity comparison
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["input": "The quick brown fox jumps over the lazy dog"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/embeddings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```