POST /api/v1/hub/embeddings computes one or more embeddings synchronously, with the OpenAI Embeddings contract. A client built with an OpenAI SDK only needs to change its base URL to https://fanifyai.com/api/v1/hub.
Compute embeddings
GET /api/v1/hub/models: their output_modalities contain embeddings. text-embedding-3-small returns vectors of 1,536 dimensions. Call an embeddings model through this route only; the other routes, including POST /api/v1/hub/generations, reject it with 400 invalid_input, and this route rejects chat, decision, transcription, and media models the same way.
Request
An
input array can contain strings, arrays of tokens, or arrays of strings: each element gives one embedding. The Hub checks only model, input, and stream; the other fields are forwarded unchanged and the model validates them. provider is ignored: the Hub chooses the route. stream is refused: embeddings are not streamed.
Batches
Send up to 2,048 texts in oneinput array. A batch is one call: one generation, one charge, and one vector per text in data, identified by index. Batching many short texts is faster than sending them one by one.
float or base64
With float, each embedding is an array of numbers. With base64, it is a string that encodes the same values as little-endian 32-bit floats: the response is about four times smaller. Without encoding_format, the model’s default applies. The official OpenAI SDKs request base64 and decode it for you, so your code always reads numbers.
To decode base64 yourself:
Response
text-embedding-3-small returns 1,536 values per vector.
The model’s response is forwarded as is, with these changes: id is the Hub generation identifier, model is the catalog id, usage.cost is the billed amount in EUR, and provider details are removed. data is never modified.
A 200 response also includes:
X-Fanify-Billed-Cost is the billed amount in EUR, always written with a dot as decimal separator. To read it with the Python SDK, use client.embeddings.with_raw_response.create(...), then raw.headers["X-Fanify-Billed-Cost"] and raw.parse(). With the .NET SDK, read result.GetRawResponse().Headers.
Each call is recorded as a generation with is_llm: true: it appears in GET /api/v1/hub/generations (excluded by media_only=true) and triggers the generation.running and generation.completed webhooks. The Hub never stores vectors: the generation and the webhooks contain only a summary (number of vectors, dimensions, encoding format, usage).
Vector compatibility
The same model always gives the same vectors through the Hub as through its original provider: an index built elsewhere withtext-embedding-3-small at 1,536 dimensions remains usable. A reduced dimensions (for example 512) gives smaller vectors that are incompatible with an existing 1,536-dimension index.
Idempotency
Idempotency-Key is not used on this route: a key you send is ignored, with no replay and no conflict. Embeddings are recomputed on retry; the cost is negligible.
Errors
Errors use the OpenAI-compatible envelope:error.metadata.provider_name is present only on a provider_error, when the routed model failed. Errors raised by the Hub itself (validation, credits, rate limit, pause) have no metadata. An authentication failure returns 401 unauthorized as Problem Details, before the request is processed.
Embeddings have their own request rate limit per key, separate from the other Hub routes. A failed request is never billed. See Errors for the meaning of each code.
Pricing
Embeddings are billed per input token, at theinput_cost_per_million rate shown for your account in GET /api/v1/hub/models; output_cost_per_million is usually 0. A batch is billed once, from the tokens of all its texts. The billed amount is rounded up to six decimal places: a call with a non-zero cost is billed at least €0.000001, never €0.