ITcompressor IT — compressed and to the point
← Back to articles

Decision models and embeddings via any-router

Chat is only part of the load on an LLM fleet. Autonomous agents live on decision calls (typed questions about JSON state: «pick an option», «ready/not ready», «a score on a scale»), and document search lives on embeddings. The good news: both call types go through the same OpenAI-compatible router any-router as chat — they need no separate address or token.

Decision API: /v1/systemone#

The contract is simple. The client sends a state and a list of questions; each question is one of the types: choice (options + criteria), bool, noul (a score on a scale):

POST /v1/systemone
{
  "model": "relay/nimble:9b",
  "state": {
    "task": "Fix a failing test",
    "progress": "3/4 tests green"
  },
  "questions": {
    "task_type": {
      "type": "choice",
      "choices": ["bug-fix", "refactor", "feature"],
      "criteria": {
        "bug-fix": "The change fixes a defect without new features",
        "refactor": "The structure improved, behavior unchanged",
        "feature": "New functionality added"
      }
    },
    "done": {
      "type": "noul",
      "instructions": "Is the task done?",
      "criteria": { "0": "no", "1": "almost", "2": "yes", "3": "yes, beyond expectations" }
    }
  }
}

The answer is the same shape with answers and probabilities:

{
  "answers": {
    "task_type": { "answer": "bug-fix", "probabilities": { "bug-fix": 0.93, "refactor": 0.05, "feature": 0.02 } },
    "done": { "answer": 2, "probabilities": { "0": 0.01, "1": 0.12, "2": 0.85, "3": 0.02 } }
  }
}

Passthrough and fallback — why any model works#

The router looks at model capabilities:

  • a model with the decision capability (for example, a llama.cpp server with classifier models, or a relay with a native API) — the request goes to the upstream's native Decision API transparently (the answer is already JSON, no SSE);
  • a plain chat model — the SystemOneRequest is converted to /v1/chat/completions with response_format: json_schema (choice options — straight from the criteria, the scale range — from its length); if the upstream refuses structured output — a retry as plain chat and JSON parsed from the text.

The point: the client is always the same, and the decision channel can be pointed at any chat model capable of grading. In practice: small fast models often grade «done/not done» no worse than flagships — and cost several times less (pick by your own benchmark for the task profile: gates are frequent, so cost and latency matter more than the quality ceiling).

Where it is used#

The classic for autonomous agents is completion gates: the worker sends its state, the decision model answers «done/not done» with probabilities, and the orchestrator decides whether to stop the loop or keep going. Plus subtask routing (choice), result quality grading (noul), filtering the agent's own output. A decision model at the gate is more reliable than «ask the chat to answer in json»: the contract with probabilities, and the fallback is built in.

Embeddings: /v1/embeddings#

Also a standard OpenAI route (passthrough to the provider):

curl -s "$YOUR_HOST/v1/embeddings" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "ollama/nomic-embed-text-v2-moe:latest",
        "input": ["how to set up a llama.cpp stand", "KV cache quantization"]
      }' | jq '.data[0].embedding | length'

Model choice — by three dimensions for your task profile (retrieval/NDCG, classification/micro-F1, semantic similarity/STS). Working candidates are nomic-embed-text-v2-moe and qwen3-embedding (0.6b to 8b — by resource); measure on your own tasks (even a mini-set of queries is cheaper than a mistaken size). Embedding models are VRAM-cheap — keeping a couple of different sizes locally is reasonable: a small one for live search, a big one for re-indexing.

Practices:

  • token permissions — like chat: you can grant only provider/* of embedding models, and the client will not see chat at all;
  • GET /v1/models helps to assemble available embedding models with a capability filter (embedding);
  • in Langfuse embedding requests are traced the same way — indexing volume and latency are visible.

Three calls — three snippets#

All examples use placeholders ($YOUR_HOST, $TOKEN); the full set for your token and permissions is in the router admin, the «Examples» tab:

# chat
curl -s "$YOUR_HOST/v1/chat/completions" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"model":"PROVIDER/MODEL","messages":[{"role":"user","content":"ping"}]}' | jq

# decision — the same token, another path
curl -s "$YOUR_HOST/v1/systemone" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"model":"PROVIDER/MODEL","state":{"s":"state"},"questions":{"done":{"type":"bool","criteria":{"true":"done","false":"not"}}}}' | jq

# embeddings
curl -s "$YOUR_HOST/v1/embeddings" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"model":"PROVIDER/EMBED-MODEL","input":"ping"}' | jq '.data[0].embedding | length'

In short: chat, decisions and embeddings — one address, one token, one permission format. The router only decides which upstream serves the call and traces to Langfuse.

Where to continue#

← Back to articles