Skip to content
Browse the docs

API reference · Embeddings

Create embeddings

POSThttps://api.useunbound.ai/v1/embeddings

Turns one or more texts into vectors. Priced by input tokens: the worst case is held before the call and only the tokens the model counted are charged. At most 256 texts and 512 KB in one request.

Headers

  • Authorizationstringrequired

    Bearer <key>, with a key from Settings → API.

  • Idempotency-Keystring

    Any unique string up to 200 characters. A repeat of a call that is running or has run is refused with 409 instead of being charged twice.

Body

application/json

  • modelstringrequired

    An id from GET /v1/models with "type": "embedding".

  • inputstring | string[]required

    A text, or a list of texts.

  • dimensionsinteger

    Length of each vector, for models that can shorten it.

    Minimum 1

  • encoding_formatstringdefault "float"

    Numbers, or little-endian 32-bit floats in base64.

    One offloatbase64

Response

One vector for each text, in the same order.

  • objectstringrequired

    One oflist

  • dataobject[]required

    • objectstring

      One ofembedding

    • indexinteger

      Position of the text in input.

    • embeddingnumber[] | string

      The vector.

  • modelstringrequired

  • usageobjectrequired

    • prompt_tokensinteger

    • total_tokensinteger

Errors

  • 400The request is malformed, or a parameter is not supported by the model.
  • 401The API key is missing, revoked or expired.
  • 402Not enough credit, or the key reached its spending limit. Nothing was charged.
  • 403The key does not have the scope this endpoint needs.
  • 404The model does not exist or is not available through the API.
  • 409This Idempotency-Key was already used.
  • 413The request body is larger than 1 MB.
  • 429Too many requests for this key. Retry after the number of seconds in the Retry-After header.
  • 502The upstream provider failed. The hold was released; you were not charged.

All errors use the envelope described in the introduction. None of them result in a charge.