API template library

Simulate the Hugging Face Text Embeddings Inference API

A WireMock simulation of Hugging Face's REST API — covering dense, sparse and unpooled embeddings, reranking, sequence classification, tokenization, and the OpenAI-compatible embeddings route.

Vendor
Hugging Face
Functionality
Embeddings, reranking, tokenization
Spec version
1.9.4
Endpoints
12
Stubs
29
Protocol
REST
Validation
AI-validated Before publication, an AI agent exercised these endpoints against the real Hugging Face API through WireMock's recording proxy, and the recorded traffic was used to verify each stub's request and response shapes.

Live sandbox · no signup, no API key

Hugging Face Text Embeddings Inference

A running WireMock Cloud instance of this template, callable right now from a terminal, a script, or an AI agent.

Base URL
https://oz63kz.wiremockapi.cloud

POST Decode input ids [decode]

curl -s -X POST 'https://oz63kz.wiremockapi.cloud/decode' \
  -H 'Content-Type: application/json' \
  -d '{}'

GET Health check method [health]

curl -s -X GET 'https://oz63kz.wiremockapi.cloud/health'

POST Get Embeddings. Returns a 424 status code if the model is not an embedding model. [embed]

curl -s -X POST 'https://oz63kz.wiremockapi.cloud/embed' \
  -H 'Content-Type: application/json' \
  -d '{}'
Method Path Summary
POST /decode Decode input ids
POST /embed Get Embeddings. Returns a 424 status code if the model is not an embedding model.
POST /embed_all Get all Embeddings without Pooling.
POST /embed_sparse Get Sparse Embeddings. Returns a 424 status code if the model is not an embedding model with SPLADE pooling.
GET /health Health check method
GET /info Text Embeddings Inference endpoint info
GET /metrics Prometheus metrics scrape endpoint
POST /predict Get Predictions. Returns a 424 status code if the model is not a Sequence Classification model
POST /rerank Get Ranks. Returns a 424 status code if the model is not a Sequence Classification model with
POST /similarity Get Sentence Similarity. Returns a 424 status code if the model is not an embedding model.
POST /tokenize Tokenize inputs
POST /v1/embeddings OpenAI compatible route. Returns a 424 status code if the model is not an embedding model.

Unauthenticated WireMock Cloud demo sandbox for Hugging Face — not an official Hugging Face sandbox, and it returns simulated example data only.

What's inside the TEI template

The template stands in for a self-hosted Text Embeddings Inference server, following the TEI 1.9.4 spec. There's nothing to create or store, so every response is computed from the request instead: embed returns one vector per input, rerank returns index and score pairs for the texts you send, and the OpenAI-style route wraps vectors in a list object with the model name. A retrieval pipeline wired to TEI can run its full indexing path without a GPU behind it.

  • Embeddings — pooled vectors from /embed, per-token vectors from /embed_all, and SPLADE-style sparse vectors from /embed_sparse
  • Reranking and similarity — scores for a query against a list of texts, and sentence-similarity scores
  • Classification — /predict for sequence-classification models
  • Tokenization — tokenize text into ids and decode ids back into text
  • Server routes — model info, health and Prometheus metrics, as a deployment check would read them

Example implementation using the OpenAI Python SDK

TEI serves an OpenAI-compatible embeddings route, so the OpenAI client is the shortest way to call it; it only needs the base URL and a placeholder key:

Vector-store integrations such as LangChain's OpenAI embeddings class accept the same base URL, so a RAG pipeline can switch between a local TEI container, this mock and a production server through configuration.

That makes ingestion jobs and retrieval APIs testable in CI on machines that could never load the model, with no container start-up time.

from openai import OpenAI

# TEI serves an OpenAI-compatible /v1/embeddings route;
# it's unauthenticated, so the api_key is only a placeholder
client = OpenAI(
    base_url="https://oz63kz.wiremockapi.cloud/v1",
    api_key="unused",
)

result = client.embeddings.create(model="tei", input="What is deep learning?")
print(len(result.data[0].embedding))

Hugging Face Text Embeddings Inference mock API FAQ

TEI is self-hosted and unauthenticated by default, and so is the mock. If your deployment puts TEI behind a gateway that checks tokens, model that gateway separately.

An empty batch answers 400 with error_type Empty, and more than 32 inputs answers 413 with error_type Validation. On the OpenAI-style route both use the OpenAI error shape, so client-side batching logic can be checked against TEI's limits.

The tokenizer 422, backend 424, overload 429 and unhealthy 503 never appear, because no input reliably triggers them. Add those as stubs in your own WireMock Cloud copy to test back-off behavior.

Vendor names identify APIs represented by WireMock template sources. This page does not imply vendor endorsement, certification, partnership, or official integration status.