Skip to main content
Turn text into vectors with the embeddings endpoint. It uses the OpenAI Embeddings format, so the OpenAI SDK works with the base URL https://api.laozhang.ai/v1.

Models

These models list the Embeddings endpoint in the public pricing as of September 29, 2026. Prices are per 1M tokens; see the model catalog for current prices and token groups. Of the OpenAI models, only text-embedding-3-small and text-embedding-3-large accept the dimensions parameter for shorter vectors; text-embedding-ada-002 always returns 1536 values. For the vector sizes and options of the Alibaba models, see Alibaba Cloud Model Studio: Embedding. These models accept text only; they do not embed images directly:
  • To search images by content, describe each image with a vision model first, then embed the description.
  • Don’t pass a Base64 image as the input string. The request still returns a vector, but it represents the characters, not the picture.

Create embeddings

Create an API key in Token management and export it in your terminal:
The Python example prints the cosine similarity between the first text and each of the others. The password-change text should score higher than the office-hours text because it is closer in meaning.

Read the response

The response holds one entry per input. In this shortened example, each vector is cut to three values; text-embedding-3-small returns 1536:
data[i].index is the position of the input text in your request. Sort by index, or look entries up by it, before you store vectors next to their texts. usage shows the tokens counted for the request; the charge appears in call logs.

Request shorter vectors

With the client from the Python example, add dimensions when you call a text-embedding-3 model:
Shorter vectors use less storage and compute, but can lower retrieval quality. Evaluate the size on your own data before you index a large collection.

Use the vectors

  • Embed stored documents and search queries with the same model and the same dimensions. Vectors from different models or sizes cannot be compared, so re-embed stored documents when you change either.
  • Each model limits how long one input can be and how many inputs one request can hold. Split long documents into chunks and send large collections in batches.
  • Cosine similarity is a common way to compare vectors. Configure your vector database with the same distance metric.

Handle errors

  • 400: check model, remove empty strings from input, shorten over-long texts, and send dimensions only to a text-embedding-3 model.
  • 401: check the Authorization: Bearer header and the API key.
  • 404 or model not available: check the exact model ID and your token group in the model catalog.
  • 429 or 5xx: check call logs before retrying, and retry with backoff.