Text Embeddings Inference serve

swaleio/tei-serve

Category: Machine learning & AI Latest version 1.10.0 · 2026-12-01 View versions

Text Embeddings Inference serve

Starts Hugging Face's Text Embeddings Inference (TEI) server for an embedding, reranker or sequence-classification model. It answers on:

  • POST /embed, with {"inputs": ["text", ...]}, returning one vector per input;
  • POST /v1/embeddings, the OpenAI-compatible form, with {"input": ["text", ...], "model": "<any name>"};
  • POST /rerank, with {"query": "...", "texts": ["...", ...]}, for reranker models;
  • GET /health, which returns 200 once the model is loaded.

model accepts a Hub repo id, downloaded into the task's home directory when the server starts, or the full path of a local model directory, such as one swaleio/hf-download fetched. TEI supports the BERT, XLM-RoBERTa, ModernBERT, GTE, Nomic, Qwen3 and other embedding architectures; a model's Hub page shows the text-embeddings-inference tag when TEI can serve it.

This is a runner task: it serves requests indefinitely and never exits on its own. Its lifetime is bounded by its own terminate_on list — the platform terminates the runner when the tasks listed there complete. A workflow that starts this task without wiring terminate_on never finishes.

Inputs

Input Required Default Description
model yes — Hub repo id (e.g. BAAI/bge-small-en-v1.5) or a full local model directory path (e.g. ${{env.WORKFLOW_STORAGE}}/bge from swaleio/hf-download). A local path skips the Hub download.
port no 8080 Port the server listens on. Consumers combine it with the runner's ip-address, so every consumer URL must use the same port.
token no — HF access token for gated/private Hub models (pass a secret); delivered to the server as HF_TOKEN via the definition's exec.env. Unneeded for public models or local directories.

Outputs

None. Runner tasks are long-lived pods terminated via terminate_on and get no output-tracking sidecar, so this task declares no outputs. Consumers read the server's responses over HTTP instead.

Compute

GPU required. The image holds TEI's CUDA builds for the A100 and H100 and picks the one for the GPU it finds; it does not start on a CPU compute type. Embedding models are small, so any GPU compute type fits them; the GPU's throughput is what the server is for.

Runner lifecycle and consumers

  • Termination: the runner's own terminate_on lists its consumers. When every task in that list completes, the platform terminates the runner.
  • Address: consumers reach the server at ${{tasks.<id>.ip-address}} on the server's port — 8080 unless the step passed port.
  • Ordering: every consumer MUST list the runner in its own start_on — the address only exists once the runner task has started.
  • Readiness: the address is available at pod start, which is before the model is loaded. Consumers poll GET /health until it returns 200, with swaleio/http-request and retry: "360", retry_delay: "5": a check every 5 seconds for up to 30 minutes.

Example

Serve a small English embedding model, wait for it to load, embed two sentences, and let the request's finish terminate the server. BAAI/bge-small-en-v1.5 is MIT.

name: TEI serve example
compute_type: cpu-4
entry_point: main

blocks:
  main:
    tasks:
      serve:
        name: Serve embeddings
        uses: swaleio/tei-serve
        compute_type: a100-1
        terminate_on: [embed]
        args:
          model: BAAI/bge-small-en-v1.5

      wait_ready:
        name: Wait for server
        uses: swaleio/http-request
        start_on: [serve]
        args:
          url: http://${{tasks.serve.ip-address}}:8080/health
          retry: "360"
          retry_delay: "5"
          expected_status: "200"

      embed:
        name: Embed
        uses: swaleio/http-request
        start_on: [wait_ready]
        args:
          url: http://${{tasks.serve.ip-address}}:8080/embed
          method: POST
          headers: |
            Content-Type: application/json
          body: '{"inputs":["Swale runs workflows.","Embeddings map text to vectors."]}'
          expected_status: "200"
          response_path: ${{env.WORKFLOW_STORAGE}}/embeddings.json

Later tasks read the vectors at ${{env.WORKFLOW_STORAGE}}/embeddings.json.


For the workflow syntax these examples use, see the workflow definition reference in the Swale documentation.

Licensed under the MIT License.