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

# Create Embeddings

POST https://api.meshapi.ai/v1/embeddings
Content-Type: application/json

Reference: https://developers.meshapi.ai/api-reference/mesh-api/embeddings/create-embeddings

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/embeddings:
    post:
      operationId: create-embeddings
      summary: Create Embeddings
      tags:
        - embeddings
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Embedding response
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
servers:
  - url: https://api.meshapi.ai
    description: Production Server
components:
  schemas:
    MultimodalEmbeddingInputType:
      type: string
      enum:
        - text
        - image_url
        - video_url
      title: MultimodalEmbeddingInputType
    ImageEmbeddingUrl:
      type: object
      properties:
        url:
          type: string
      required:
        - url
      title: ImageEmbeddingUrl
    VideoEmbeddingUrl:
      type: object
      properties:
        url:
          type: string
      required:
        - url
      title: VideoEmbeddingUrl
    MultimodalEmbeddingInput:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/MultimodalEmbeddingInputType'
        text:
          type:
            - string
            - 'null'
        image_url:
          oneOf:
            - $ref: '#/components/schemas/ImageEmbeddingUrl'
            - type: 'null'
        video_url:
          oneOf:
            - $ref: '#/components/schemas/VideoEmbeddingUrl'
            - type: 'null'
      required:
        - type
      description: >-
        A single item in a BytePlus multimodal embeddings input list.


        BytePlus /embeddings/multimodal accepts a list of typed content objects

        instead of plain strings. All items in one request are vectorized
        together

        as a single unit (e.g. one image + one text → one combined vector).
      title: MultimodalEmbeddingInput
    EmbeddingsRequestInput4:
      type: array
      items:
        $ref: '#/components/schemas/MultimodalEmbeddingInput'
      title: EmbeddingsRequestInput4
    EmbeddingsRequestInput:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
        - type: array
          items:
            type: integer
        - type: array
          items:
            type: array
            items:
              type: integer
        - $ref: '#/components/schemas/EmbeddingsRequestInput4'
      description: >-
        Text(s) to embed. Accepts a string, list of strings, list of token IDs,
        list of token ID lists, or a list of MultimodalEmbeddingInput objects
        (for BytePlus multimodal embedding models).
      title: EmbeddingsRequestInput
    EmbeddingsRequestEncodingFormat:
      type: string
      enum:
        - float
        - base64
      description: Format of the returned embedding. Defaults to `float`.
      title: EmbeddingsRequestEncodingFormat
    ProviderPreferencesDataCollection:
      type: string
      enum:
        - allow
        - deny
      description: Control whether the provider may use the request for training.
      title: ProviderPreferencesDataCollection
    ProviderPreferences:
      type: object
      properties:
        order:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Preferred provider order, e.g. ['perplexity', 'openai'].
        allow_fallbacks:
          type:
            - boolean
            - 'null'
          description: Whether to fall back to other providers if the first is unavailable.
        require_parameters:
          type:
            - boolean
            - 'null'
          description: Only use providers that support all requested parameters.
        data_collection:
          oneOf:
            - $ref: '#/components/schemas/ProviderPreferencesDataCollection'
            - type: 'null'
          description: Control whether the provider may use the request for training.
      description: OpenRouter provider routing preferences.
      title: ProviderPreferences
    EmbeddingsRequestProvider:
      oneOf:
        - type: string
        - $ref: '#/components/schemas/ProviderPreferences'
      description: >-
        Provider routing preferences. Pass a provider slug string (e.g.
        `'perplexity'`) or a `ProviderPreferences` object to control fallback
        and ordering behaviour.
      title: EmbeddingsRequestProvider
    EmbeddingsRequest:
      type: object
      properties:
        model:
          type:
            - string
            - 'null'
          description: Model ID to use for embedding, e.g. `perplexity/pplx-embed-v1-4b`.
        input:
          $ref: '#/components/schemas/EmbeddingsRequestInput'
          description: >-
            Text(s) to embed. Accepts a string, list of strings, list of token
            IDs, list of token ID lists, or a list of MultimodalEmbeddingInput
            objects (for BytePlus multimodal embedding models).
        dimensions:
          type:
            - integer
            - 'null'
          description: >-
            Number of dimensions for the output embedding vector
            (model-dependent).
        encoding_format:
          oneOf:
            - $ref: '#/components/schemas/EmbeddingsRequestEncodingFormat'
            - type: 'null'
          description: Format of the returned embedding. Defaults to `float`.
        input_type:
          type:
            - string
            - 'null'
          description: >-
            Intended use of the embedding, e.g. `query` or `document`. Some
            models use this to apply asymmetric embedding.
        provider:
          oneOf:
            - $ref: '#/components/schemas/EmbeddingsRequestProvider'
            - type: 'null'
          description: >-
            Provider routing preferences. Pass a provider slug string (e.g.
            `'perplexity'`) or a `ProviderPreferences` object to control
            fallback and ordering behaviour.
        user:
          type:
            - string
            - 'null'
          description: End-user identifier for abuse monitoring (forwarded to OpenRouter).
        instructions:
          type:
            - string
            - 'null'
          description: >-
            Inference prompt for BytePlus multimodal embeddings. A default is
            generated from the input modality if not set.
        sparse_embedding:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
          description: >-
            Sparse vector switch for BytePlus text embeddings. Pass {"type":
            "enabled"} to return both dense and sparse vectors, or {"type":
            "disabled"} for dense only.
      required:
        - input
      description: >-
        Request body for `POST /v1/embeddings`.


        Mirrors the OpenAI / OpenRouter embeddings API. The `input` field
        accepts

        four shapes:


        - **string** — a single text to embed

        - **list[string]** — a batch of texts

        - **list[int]** — a single pre-tokenised input (token IDs)

        - **list[list[int]]** — a batch of pre-tokenised inputs
      title: EmbeddingsRequest
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## Examples

### Successful embedding response



**Request**

```json
undefined
```

**Response**

```json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        -0.03264831379055977,
        -0.03786936774849892,
        0.007462255656719208
      ]
    }
  ],
  "model": "bedrock/amazon.titan-embed-text-v2:0",
  "usage": {
    "prompt_tokens": 3,
    "total_tokens": 3
  }
}
```

**SDK Code**

```python Successful embedding response
import requests

url = "https://api.meshapi.ai/v1/embeddings"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Successful embedding response
const url = 'https://api.meshapi.ai/v1/embeddings';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Successful embedding response
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/embeddings"

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Successful embedding response
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/embeddings")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'

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

```java Successful embedding response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/embeddings")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Successful embedding response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/embeddings', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Successful embedding response
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/embeddings");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Successful embedding response
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

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

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()
```

### Example request



**Request**

```json
{
  "input": "The quick brown fox jumps over the lazy dog.",
  "model": "openai/text-embedding-3-small"
}
```

**Response**

```json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        -0.03264831379055977,
        -0.03786936774849892,
        0.007462255656719208
      ]
    }
  ],
  "model": "bedrock/amazon.titan-embed-text-v2:0",
  "usage": {
    "prompt_tokens": 3,
    "total_tokens": 3
  }
}
```

**SDK Code**

```python Example request
import requests

url = "https://api.meshapi.ai/v1/embeddings"

payload = {
    "input": "The quick brown fox jumps over the lazy dog.",
    "model": "openai/text-embedding-3-small"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example request
const url = 'https://api.meshapi.ai/v1/embeddings';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"input":"The quick brown fox jumps over the lazy dog.","model":"openai/text-embedding-3-small"}'
};

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

```go Example request
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/embeddings"

	payload := strings.NewReader("{\n  \"input\": \"The quick brown fox jumps over the lazy dog.\",\n  \"model\": \"openai/text-embedding-3-small\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Example request
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/embeddings")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"The quick brown fox jumps over the lazy dog.\",\n  \"model\": \"openai/text-embedding-3-small\"\n}"

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

```java Example request
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/embeddings")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"The quick brown fox jumps over the lazy dog.\",\n  \"model\": \"openai/text-embedding-3-small\"\n}")
  .asString();
```

```php Example request
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/embeddings', [
  'body' => '{
  "input": "The quick brown fox jumps over the lazy dog.",
  "model": "openai/text-embedding-3-small"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Example request
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/embeddings");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"The quick brown fox jumps over the lazy dog.\",\n  \"model\": \"openai/text-embedding-3-small\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "The quick brown fox jumps over the lazy dog.",
  "model": "openai/text-embedding-3-small"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/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()
```