POST
/
openai
/
{region}
/
v1
/
embeddings
curl --request POST \
  --url https://api.langdock.com/openai/{region}/v1/embeddings \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "text-embedding-ada-002",
  "input": "The quick brown fox jumps over the lazy dog",
  "encoding_format": "float"
}'
{
  "data": [
    {
      "embedding": [
        0.0023064255,
        -0.009327292,
        "..."
      ],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "text-embedding-ada-002",
  "object": "list",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

In dedicated deployments, api.langdock.com maps to <Base URL>/api/public

Creates embeddings for text using OpenAI’s embedding models. This endpoint follows the OpenAI API specification and the requests are sent to the Azure OpenAI endpoint.

To use the API you need an API key. Admins can create API keys in the settings.

All parameters from the OpenAI Embeddings endpoint are supported according to the OpenAI specifications, with the following exceptions:

  • model: Currently only the text-embedding-ada-002 model is supported.
  • encoding_format: Supports both float and base64 formats.

Rate limits

The rate limit for the Embeddings endpoint is 500 RPM (requests per minute) and 60.000 TPM (tokens per minute). Rate limits are defined at the workspace level - and not at an API key level. If you exceed your rate limit, you will receive a 429 Too Many Requests response.

Please note that the rate limits are subject to change, refer to this documentation for the most up-to-date information. In case you need a higher rate limit, please contact us at support@langdock.com.

Using OpenAI-compatible libraries

As the request and response format is the same as the OpenAI API, you can use popular libraries like the OpenAI Python library or the Vercel AI SDK to use the Langdock API.

Example using the OpenAI Python library

from openai import OpenAI
client = OpenAI(
  base_url="https://api.langdock.com/openai/eu/v1",
  api_key="<YOUR_LANGDOCK_API_KEY>"
)

embedding = client.embeddings.create(
  model="text-embedding-ada-002",
  input="The quick brown fox jumps over the lazy dog",
  encoding_format="float"
)

print(embedding.data[0].embedding)

Example using the Vercel AI SDK in Node.js

import { createOpenAI } from "@ai-sdk/openai";

const langdockProvider = createOpenAI({
  baseURL: "https://api.langdock.com/openai/eu/v1",
  apiKey: "<YOUR_LANGDOCK_API_KEY>",
});

const response = await langdockProvider.embeddings.create({
  model: "text-embedding-ada-002",
  input: "The quick brown fox jumps over the lazy dog",
  encoding_format: "float",
});

console.log(response.data[0].embedding);

Path Parameters

region
enum<string>
required

The region of the API to use.

Available options:
eu,
us

Body

application/json
input
required

Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of tokens, e.g. ["text1", "text2"]. Each input must not exceed 8192 tokens in length.

model
required

ID of the model to use. You can use the List models API to see all of your available models, or see OpenAI's Model overview for descriptions of them.

encoding_format
enum<string>
default:float

The format to return the embeddings in. Can be either float or base64.

Available options:
float,
base64
dimensions
integer

The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.

Required range: x >= 1
user
string

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

Response

200
application/json
OK
data
object[]
required

The list of embeddings generated by the model.

model
string
required

The name of the model used to generate the embedding.

object
enum<string>
required

The object type, which is always "list".

Available options:
list
usage
object
required