AI

Create embeddings

Returns one embedding vector per input string. The request and success bodies follow the OpenAI embeddings API shape; error bodies use the standard B4M error envelope. model is any embedding model this deployment supports (OpenAI, Voyage AI, Amazon Bedrock, or a self-hosted Ollama model); input is a string or up to 2048 strings, at most 300000 tokens in total and each within the model context window. The input count is further capped so inputs x output width stays within 196608 values (128 inputs at 1536 dimensions) - page larger jobs across requests. Pre-tokenized input (arrays of token ids) is not accepted; clients that send it by default, such as LangChain's Python OpenAIEmbeddings, must be set to send strings (check_embedding_ctx_length=False). dimensions shortens the vector on models that support it (OpenAI text-embedding-3-*, and Voyage models with several published widths). Billed in credits per input token from the per-model embedding rate, reserved before the provider call and refunded if it fails. Authenticate with an API key (b4m_live_) carrying ai:generate, or a JWT.

post/api/v1/embeddings

Request

  • Base URL: https://your-deployment.example.com
  • URL: https://your-deployment.example.com/api/v1/embeddings
  • Auth: one of:
    • HTTP bearer
    • API key in header x-api-key

Request body

dimensionsinteger
encoding_format'float' | 'base64'

Example request

{
  "model": "text-embedding-3-small",
  "input": [
    "The quick brown fox",
    "jumps over the lazy dog"
  ],
  "dimensions": 1024
}

Response

One embedding per input, in input order.

object'list' required
modelstring required

Example response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        0.0023,
        -0.0093,
        0.0158
      ]
    },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [
        -0.0112,
        0.0047,
        0.0201
      ]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.