embedx Specification
Defines an embedding service with an Ollama-compatible HTTP API using Go and Python FastEmbed subprocess with pipe communication.
What this file does
Defines an embedding service with an Ollama-compatible HTTP API using Go and Python FastEmbed subprocess with pipe communication.
When to use it
- Building a self-hosted embedding service with Ollama-compatible API
- Replacing Ollama's embedding endpoint with a FastEmbed backend
- Integrating Go and Python via subprocess pipes for ML inference
- Creating a drop-in embedding server for existing Ollama clients
Assumes this stack
embedx Specification
Overview
embedx is a FastEmbed-powered embedding service with a drop-in Ollama-compatible HTTP API. It uses Go for HTTP and Python subprocess with pipe communication for FastEmbed.
Architecture
Components
- Go HTTP Server - Exposes Ollama-compatible API on port 11434
- Python Subprocess - FastEmbed backend, called via stdin/stdout pipes with JSON protocol
Data Flow
Client Request (Ollama-compatible API)
↓
Go HTTP Server (:11434)
↓ JSON via stdin/stdout pipe
Python Subprocess (FastEmbed)
↓
Return embedding / status to client
API Specification
POST /api/embeddings
Ollama-compatible embedding generation.
Request:
{
"model": "BAAI/bge-small-zh-v1.5", // optional, defaults to EMBEDX_MODEL
"prompt": "your text here"
}
Response:
{
"embedding": [0.003, 0.064, -0.045, ...]
}
POST /api/pull
Ollama-compatible model download.
Request:
{
"name": "BAAI/bge-base-zh-v1.5",
"stream": false
}
Response (non-streaming):
{
"status": "success",
"model": "BAAI/bge-base-zh-v1.5",
"dimensions": 768
}
Response (streaming, SSE):
event: status
data: {"status":"pulling","model":"BAAI/bge-base-zh-v1.5"}
event: done
data: {"status":"success","model":"BAAI/bge-base-zh-v1.5"}
POST /api/create
Load a model into memory (does not persist, use /api/pull for that).
Request:
{"name": "BAAI/bge-base-zh-v1.5"}
Response:
{"status": "success", "model": "BAAI/bge-base-zh-v1.5", "dimensions": 768}
POST /api/show
Get model information after loading.
Request:
{"name": "BAAI/bge-base-zh-v1.5"}
GET /api/tags
List available (cached) models.
Response:
{
"models": [
{"name": "BAAI/bge-small-zh-v1.5", "model": "BAAI/bge-small-zh-v1.5", "size": 0}
]
}
GET /health
Health check - returns 200 OK.
Python Protocol
Go communicates with Python via JSON messages on stdin/stdout.
Commands (Go → Python)
{"command": "embed", "model_name": "...", "texts": ["..."]}
{"command": "load", "model_name": "..."}
{"command": "pull", "model_name": "..."}
{"command": "unload", "model_name": "..."}
{"command": "list_cached"}
Responses (Python → Go)
{"type": "embed_done", "embeddings": [[0.1, 0.2, ...]]}
{"type": "model_loaded", "model": "...", "dimensions": 512, "cached": ["..."]}
{"type": "pull_done", "model": "...", "dimensions": 512}
{"type": "error", "error": "..."}
Configuration
| Variable | Default | Description |
|---|---|---|
EMBEDX_PORT | 11434 | HTTP server port |
EMBEDX_MODEL | BAAI/bge-small-zh-v1.5 | Default embedding model |
Supported Models
All FastEmbed-supported models. Popular choices:
| Model | Dimensions | Languages |
|---|---|---|
BAAI/bge-small-zh-v1.5 | 512 | Chinese + English |
BAAI/bge-base-en-v1.5 | 768 | English |
nomic-ai/nomic-embed-text-v1.5 | 768 | English (multimodal) |
jinaai/jina-embeddings-v2-base-en | 768 | English |
mixedbread-ai/mxbai-embed-large-v1 | 1024 | English |
File Structure
embedx/
├── main.go # Go HTTP server + subprocess management
├── embed.py # Python CLI (stdin/stdout protocol)
├── go.mod # Go module
├── Makefile # Build commands
├── README.md # User documentation
└── SPEC.md # This file
What's inside
6 API endpoints, 5 Python commands, 5 response types, 4 config variables, 5 example models, file structure
Change this for your project
- Replace
BAAI/bge-small-zh-v1.5with your default model - Replace
BAAI/bge-base-zh-v1.5with your model in examples - Replace
cnlangzi/embedxwith your own repository name
Where it goes
Keep in docs/ or alongside the feature. Agents read it to implement against a defined contract.
Worth borrowing
- Go HTTP server delegating ML inference to a Python subprocess via stdin/stdout JSON protocol
- Ollama-compatible API surface enabling drop-in replacement for existing clients
Related Documents
GPU Selection Guide for Large Language Models (LLMs)
Guides GPU selection for LLM inference, fine-tuning, and training by mapping model sizes, precision levels, and budgets to VRAM requirements.
Community AI Agent Skills Discovery Sources
Catalogs 50+ platforms, repositories, directories, and communities for discovering and sharing AI agent skills across multiple coding tools.
ReleaseKit - Technical Requirements Document
Specifies a Go library and CLI for release automation with conventional commit parsing, validation checks, and workflow orchestration.
api_llm Specification
Defines a workspace of thin HTTP API clients for major LLM providers with no abstraction layer and explicit developer control.