OpenAI-compatible server#
The server can generate embeddings against any endpoint that speaks the OpenAI API — a self-hosted Ollama, vLLM, LiteLLM, or an internal gateway — instead of the public OpenAI API. This keeps document and query text inside your network (no external egress), which is the usual requirement for on-prem and regulated deployments.
Note
This is one of two ways to run without the public OpenAI API. Use an OpenAI-compatible server (this page) when a shared endpoint already hosts your embedding model. Use a local sentence-transformer model loaded in-process (see Local (offline) embeddings) when you want no network calls at all. Both avoid OpenAI egress.
Configuration#
Set three variables (all documented in Embeddings):
Variable |
Value |
|---|---|
|
|
|
The embedding model your endpoint serves (e.g. |
|
The endpoint’s base URL, e.g. |
OPENAI_API_KEY is optional here — if your endpoint does not require a key, leave it unset and the server sends a placeholder. Set it only when the endpoint enforces a token (it is sent as the bearer token).
The same OPENAI_BASE_URL also routes the optional self-query LLM when
LLM_PROVIDER=openai. Set LLM_MODEL_NAME to a chat model served by that endpoint. The
standard retrieval-only search_* tools do not use a chat LLM, so these settings are needed only
by a custom collection retriever that accesses it. Standard search still uses
ONETICK_DB_EMBEDDING_MODEL both to build the vector index and to embed each query at search time.
Example: local Ollama#
Pull an embedding model and start Ollama:
ollama pull nomic-embed-text
ollama serve # serves the OpenAI-compatible API on http://localhost:11434/v1
Point the MCP at it in .env:
ONETICK_DB_EMBEDDING_TYPE=openai
ONETICK_DB_EMBEDDING_MODEL=nomic-embed-text
OPENAI_BASE_URL=http://localhost:11434/v1
# OPENAI_API_KEY left unset — Ollama ignores it
ONETICK_DB_EMBEDDING_MODEL must be an embedding model — a chat model does not serve the embeddings endpoint.
Input encoding (the 400 invalid input type error)#
The public OpenAI API accepts embedding inputs as pre-tokenized integer token arrays, and the client library uses that form by default. Many OpenAI-compatible servers — including Ollama and some vLLM / LocalAI builds — accept only raw strings and reject token arrays with:
openai.BadRequestError: Error code: 400 - {'error': {'message': 'invalid input type', ...}}
Because OPENAI_BASE_URL is set, the server automatically switches to raw strings, so this works out of the box. The behaviour is controlled by OPENAI_EMBEDDINGS_CHECK_CTX_LENGTH:
unset (default) — auto: raw strings when
OPENAI_BASE_URLis set, token arrays for the public OpenAI API.false— always send raw strings.true— always send pre-tokenized token arrays. Set this only if your endpoint requires the tokenized form.
Re-index after changing the model#
Switching to a local endpoint, or changing ONETICK_DB_EMBEDDING_MODEL, requires rebuilding the search index — see Re-index after changing the model.