# Tei

> Use when the user wants to call Hugging Face Text Embeddings Inference (TEI) to check health or model info, generate embeddings, create sparse embeddings, rerank candidate texts, tokenize input, or use the OpenAI-compatible embeddings endpoint. Trigger phrases include "embed this text", "convert to a vector", "rerank these results", "what model is my TEI server running", "tokenize this sentence", and "check TEI health".

- Skill: `dinglebear-ai/tei` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx skillmds@latest add dinglebear-ai/tei`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dinglebear-ai/tei/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: dinglebear-ai (https://skillmd.com/u/dinglebear-ai)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/dinglebear-ai/tei

---


# TEI

Hugging Face Text Embeddings Inference server: embed text, rerank candidates, and tokenize input through the TEI HTTP API.

## How to call it

Prefer `scripts/tei-api.sh` for common TEI requests. It resolves `TEI_URL` and
optional `TEI_AUTH_HEADER` from the plugin-generated config first, then the
environment or legacy `~/.lab/.env`, and exposes `health`, `info`, `embed`,
`embed-batch`, `sparse`, `rerank`, `tokenize`, and `openai-embed`.

Configure `tei_url` and optional sensitive `tei_auth_header` in Claude plugin
settings or Gemini extension settings. The hook writes
`${XDG_CONFIG_HOME:-~/.config}/lab-tei/config.env` with mode `600`.

Use the TEI base URL from plugin config, the runtime environment, or legacy lab
configuration:

```bash
source "${XDG_CONFIG_HOME:-$HOME/.config}/lab-tei/config.env" 2>/dev/null || true
TEI_URL=${TEI_URL:-$(grep -E '^TEI_URL=' ~/.lab/.env 2>/dev/null | cut -d= -f2-)}
test -n "$TEI_URL" || echo "TEI_URL is not configured"
```

TEI often runs unauthenticated on trusted networks. If the deployment is behind
auth, set `tei_auth_header` to the full header, for example
`Authorization: Bearer <token>`. Do not put real tokens in examples or committed
files.

## Common operations

| Intent | Request |
|---|---|
| Health | `curl -sS "$TEI_URL/health" -w '\nHTTP %{http_code}\n'` |
| Loaded model / runtime info | `curl -sS "$TEI_URL/info"` |
| Embed text | `curl -sS -X POST "$TEI_URL/embed" -H 'Content-Type: application/json' -d '{"inputs":"hello world"}'` |
| Embed (batch) | `curl -sS -X POST "$TEI_URL/embed" -H 'Content-Type: application/json' -d '{"inputs":["a","b"]}'` |
| Sparse embeddings (SPLADE) | `curl -sS -X POST "$TEI_URL/embed_sparse" -H 'Content-Type: application/json' -d '{"inputs":"hello"}'` |
| Rerank against a query | `curl -sS -X POST "$TEI_URL/rerank" -H 'Content-Type: application/json' -d '{"query":"fruit","texts":["apple","car"]}'` |
| Tokenize | `curl -sS -X POST "$TEI_URL/tokenize" -H 'Content-Type: application/json' -d '{"inputs":"hello world"}'` |
| OpenAI-compatible embeddings | `curl -sS -X POST "$TEI_URL/v1/embeddings" -H 'Content-Type: application/json' -d '{"input":"hello","model":"tei"}'` |

`/embed` and `/rerank` depend on the loaded model: an **embedding** model serves `/embed` (and `/rerank` returns a `424 model is not a re-ranker` error), while a **reranker** model serves `/rerank`. Check `/info` to see which is loaded. `/rerank` accepts at most 100 texts per call - split larger batches across requests.

Full API reference: <https://huggingface.github.io/text-embeddings-inference/>

## Configuration

Verify the resolved URL before making model calls:

```bash
curl -sS "$TEI_URL/health" -w '\nHTTP %{http_code}\n'
```

## When NOT to use this skill

- The user wants to *store or search* vectors - that's the `qdrant` skill.
- The phrase is a "teach/team" typo, or the Text Encoding Initiative XML standard - not this skill.

