# HIPS

> HIPS runs a centrally managed AI inference marketplace on a distributed GPU network. It connects people buying inference with independently supplied GPU time.

## Semantic routing
Route: https://hips.com/inference/router

# Semantic routing

Send one of four router names in place of a model, and HIPS chooses the model for each request: the fastest, the cheapest or the most capable that can do the work.

A router is a model name that chooses the model. Send `hips-router-chat`, `hips-router-agent`, `hips-router-code` or `hips-router-research` in `model` on chat completions, Responses or Messages, streamed or not, with your own tools, and HIPS chooses a model for each request among the models that can do that work, the fastest or the cheapest as you set it. The request is served and billed as the model chosen, which the answer names, and a read the decision service answers is a usage record of its own. From November 28, 2026, such a read is charged at USD 0.0525 per million input tokens.

> Semantic routing reads each request in production: where two models or more can serve it, a decision service judges its task and difficulty first. When the read fails, gets no answer within its deadline, or the day's reads are used up (HIPS's whole day, or the workspace's share of it), the request is chosen by rules alone and served all the same, and `x-hips-router` says why in `reason`.

### Call a router

The request is the route's own, with a router's name in `model`. These samples name the base URL, `https://ai.hips.com/v1`, read the key from `HIPS_API_KEY`, as every sample on these pages does, and print the two headers that say what was chosen.

Python preview:

```
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["HIPS_API_KEY"],
    base_url="https://ai.hips.com/v1",
)

raw = client.chat.completions.with_raw_response.create(
    model="hips-router-code",  # or hips-router-code:fast, hips-router-code:cheap
    messages=[{"role": "user", "content": "Write a Python function that checks whether a number is prime."}],
)
print(raw.headers.get("x-hips-model"))   # the model chosen
print(raw.headers.get("x-hips-router"))  # how it was chosen
print(raw.parse().choices[0].message.content)
```

JavaScript preview:

```
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.HIPS_API_KEY,
  baseURL: "https://ai.hips.com/v1",
});

const { data, response } = await client.chat.completions
  .create({
    model: "hips-router-code:fast", // fastest, for this request alone
    messages: [{ role: "user", content: "Write a Python function that checks whether a number is prime." }],
  })
  .withResponse();
console.log(response.headers.get("x-hips-model")); // the model chosen
console.log(response.headers.get("x-hips-router")); // how it was chosen
console.log(data.choices[0].message.content);
```

cURL preview:

```
curl -i https://ai.hips.com/v1/chat/completions \
  -H "Authorization: Bearer $HIPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "hips-router-chat", "messages": [{"role": "user", "content": "Explain GPU inference in two sentences."}]}'
```

The same names work on `POST /v1/responses` and `POST /v1/messages`. For a coding agent, set the agent's model to the router's name, for example `HIPS_MODEL=hips-router-code`.

### The four routers

| Name | Use case | The models it can choose |
| --- | --- | --- |
| `hips-router-chat` | Chat: conversation, questions and answers, customer support and writing | Every published, priced language model |
| `hips-router-agent` | Agent: requests that act through tools | Models whose tool calls are validated |
| `hips-router-code` | Coding: coding agents and code work | Models that passed a coding agent's test, with their tool calls validated |
| `hips-router-research` | Research: long context and reasoning | Models that advertise `reasoning` |

A model joins and leaves a router by itself as it is imported, tested and priced; no list is kept by hand. A router chooses among catalog models only: never a workspace's own deployment (`dep_...`), never a draft, deprecated or retired model, and never a model the catalog offers only to buyers in certain countries. For the Coding router, a test with the coding agent of the route you call counts first: HIPS Code or OpenCode on chat completions, Claude Code on Messages, Codex on Responses. Where no model has passed that agent's test, a test with any of the four counts.

### Fastest, cheapest or most intelligent

Each router has a preference for the workspace: Fastest sends each request to the model with the shortest measured time for its size, Cheapest to the lowest expected charge for its size at the rates its quote would bind, and Most intelligent to the most capable model that can do the work. The API names the three `fastest`, `cheapest` and `smartest`, so the Console's Most intelligent is `smartest` in `x-hips-router` and in [Models](/docs/reference/models). A router never set reads Cheapest. An owner or admin sets it on the Console's Semantic routing page; the change applies to the next requests and is recorded in the audit log. A suffix overrides the setting for one request:

| Model field | Preference | Source in the answer |
| --- | --- | --- |
| `hips-router-code` | The workspace's setting for Coding | `setting` |
| `hips-router-code:fast` | Fastest, for this request alone | `suffix` |
| `hips-router-code:cheap` | Cheapest, for this request alone | `suffix` |
| `hips-router-code:smart` | Most intelligent, for this request alone | `suffix` |

Most intelligent ranks the models by HIPS's model tiers, Frontier, Pro, Standard and Fast, as `GET /v1/models` lists them in `hips.model_tiers` (see [Models](/docs/reference/models)), then every other model by its size, the largest first. Of the models that can serve the request, the highest-ranked one with a GPU ready now serves it, so no request waits for a model to load while another is ready. Where a higher-ranked model must load, the request is counted as that model's demand, so HIPS loads it for the requests after this one. Most intelligent reads nothing first, since no read could change its order: `x-hips-router` says `read=rules; reason=same_choice`, and no read is charged. It is billed as the model it chooses, at that model's price, which may cost more than the other preferences.

- The measured time is the prompt's tokens over the measured prefill rate plus the expected output over the measured decode rate, on GPUs that hold the model loaded and free now. A model with no measured speed ranks after every model that has one, those among themselves by expected charge. Nothing is estimated from another model.
- The expected output is the request's own cap where it sets one, else the same length for every model, so a model with a long default is not made to look dear.
- A name and its suffix are lowercase, exactly as written. An empty or unknown suffix (`hips-router-code:`, `hips-router-code:best`) is 400 `invalid_value` at `model`: "The suffix of a router is `:fast`, `:cheap` or `:smart`, as in `hips-router-code:fast`."
- Any other name that starts with `hips-router`, a router written in another case included, is 404 `model_not_found`, and the message names the four. No catalog id, alias or pinned id starts with `hips-router`, so a router never collides with a model.
- A router chooses language models on chat completions, Responses and Messages only. Named on `/v1/tasks`, `/v1/embeddings` or `/v1/rerank`, it is 400 `invalid_value` at `model`.

### How a model is chosen

Semantic routing makes no promise about which model serves a request. It chooses before the first byte of the answer, in this order:

1. The candidates. The router's models, narrowed to those that can serve this request in a pool it may use: an image part needs a model that takes images, `tools` one that supports tool calls, `response_format`, `logprobs` and `logit_bias` a model that advertises them (`parallel_tool_calls` and `reasoning_effort` narrow nothing: the first is a permission, served as `false` on a model without the feature, and the second is accepted with no effect on a model without `reasoning`), the prompt a window served now that holds it, and an output cap a model whose output limit reaches it. Then the requirements (`x-hips-pool`, `x-hips-region`, `x-hips-pricing-mode`), the pools the workspace may use and your guardrails. Then the supply now: a model no GPU can serve in any of those pools is out.
2. The read. Where two models or more remain, the request may be read first: a decision service judges its task (`conversation`, `writing`, `extraction`, `reasoning`, `code` or `tool_use`) and its difficulty (`simple`, `moderate` or `hard`) from a masked excerpt. A harder request is held to larger models, and the task ranks the models that fit it first: models that reason for `reasoning`, models tested with a coding agent for `code`, validated tool calls for `tool_use`, JSON schema output for `extraction`. Without an answer the request is chosen by rules alone, among the same candidates with no size floor and no task preference. A request with a region requirement is never read. A read that fails, times out or finds the day's reads used up never fails the request: it is chosen by rules alone.
3. The order. Models with a GPU ready now go before models that start on demand, since loading a model can take minutes. Within each, the preference's measure decides, ties going to the other measure, then to the catalog id, so every gateway chooses alike. Where the read asked for a larger model and none is ready now, a smaller one that is ready goes first, and the answer says `floor=below`. Under Most intelligent the rank alone decides within each, the model tiers first, then size.
4. The conversation. Under Fastest and Cheapest, a conversation's next turn goes to the model its earlier turn was answered by, while that model is still a candidate, ready now and large enough for the new turn, so a coding agent's session stays on one model. Under Most intelligent each turn goes to the highest-ranked model ready now, so a conversation moves to a higher-ranked model once one is loaded.
5. The tries. The first model is tried as if the request had named it. If it is refused before its first byte for capacity (`no_capacity`, `pool_unavailable`, `overloaded`, `context_size_not_measured`, `model_loading`), the next one is tried, up to three models in all, within the request's own deadline. After the first byte the request is that model's: a stream that fails is never restarted on another model.

### What the answer says

Everything about the answer is the chosen model's: `model` in the body names it, never the router, `x-hips-model` carries its pinned id, and `usage` its counts in the route's own names. `x-hips-router` says how it was chosen:

Response headers:

```
HTTP/2 200
content-type: application/json
x-hips-request-id: req_...
x-hips-model: <pinned id of the model chosen>
x-hips-router: hips-router-code; preference=cheapest; source=setting; read=decision; task=code; difficulty=hard
```

*x-hips-router, its members in order*

- `<router>`: The router's name, without its suffix.
- `preference` (`fastest`, `cheapest`, `smartest`): The preference this request was chosen by.
- `source` (`setting`, `suffix`): The workspace's setting, or the request's suffix.
- `read` (`decision`, `cache`, `rules`): Read first; read first, from an earlier reading of the same masked text; or chosen by rules alone.
- `reason` (a word below): Why rules alone. Only with `read=rules`.
- `task` (`conversation`, `writing`, `extraction`, `reasoning`, `code`, `tool_use`): Only when the request was read.
- `difficulty` (`simple`, `moderate`, `hard`): Only when the request was read.
- `floor` (`below`): The model chosen is smaller than the difficulty asked, since nothing larger was ready.
- `tries` (a count): Only when more than one model was tried before one was placed.

| Reason | Why the request was chosen by rules alone |
| --- | --- |
| `no_key` | The gateway has no client for the decision service, so it cannot read |
| `one_candidate` | Only one model could serve it, so there was nothing to read for |
| `same_choice` | Every answer the read could give would try the same models in the same order, so none was asked |
| `region` | The request carries a region requirement, and such a request is never read |
| `timeout` | No answer in time |
| `error` | The read failed, or the masking could not finish within its bound and nothing was sent |
| `refused` | The decision service refused the read |
| `budget` | The day's reads are used up, HIPS's or the workspace's share |
| `unusable` | The decision service answered the read, but with nothing the Router could use; from November 28, 2026, the read is charged |
| `breaker` | Reads are paused after failures |
| `saturated` | Too many reads at once |
| `switched_off` | HIPS switched reading off |

A request the read could not answer in time is chosen by rules alone, and the header says so:

A request chosen by rules alone:

```
x-hips-router: hips-router-code; preference=cheapest; source=setting; read=rules; reason=timeout
```

`x-hips-router` is on every answer to a request that named a router, a refusal after the name was read included: a refusal found among the candidates says `read=rules` with no reason, and a content moderation block, which comes before any choice, carries the name, `preference` and `source` alone. The answer's `hips` object carries the same as `router`, with `model`, the pinned id served, and each member only where it is known:

The hips object of a chat completion:

```
"hips": {
  "cost_micros": 0,
  "latency_ms": 0,
  "quote": "quote_...",
  "router": {
    "name": "hips-router-code",
    "preference": "cheapest",
    "source": "setting",
    "read": "decision",
    "task": "code",
    "difficulty": "hard",
    "model": "<pinned id of the model chosen>"
  }
}
```

| Route | Where the router member is |
| --- | --- |
| Chat completions | The answer's top-level `hips` object; on a stream, the `hips` object of the final usage chunk (`stream_options.include_usage`) |
| Messages | `hips` on the message; on a stream, in `message_delta` |
| Responses | On a stream, the `hips` member of `response.completed`; a whole answer carries the headers alone |

The choice is made before the first byte, so `x-hips-model` and `x-hips-router` are in a stream's head, and a refusal is an ordinary status and body, never an error inside the stream.

### What it costs

A routed request is billed exactly as the model chosen: its quote (`x-hips-quote`), its rates in the pool that served it, its usage units, and `x-hips-cost-micros` or the `hips` object's `cost_micros`. There is no router fee. Reading the request is a usage record of its own, marked `decision`, whatever becomes of the request, even when its answer could not be used (`unusable`); a request chosen from a kept verdict, or by rules alone for any other reason, has no read and no record of one. From November 28, 2026, the read is charged by the input tokens the decision service counted, at USD 0.0525 per million. The usage record keeps the model chosen and, beside it, the router's name, the preference, its source, how it chose and why rules, never the task or the difficulty. Rate limits count a routed request as one request with its own tokens.

### Data handling

The read receives a masked excerpt of the request, at most 4,096 bytes: the newest user message's text, then the system text, with every email address, phone number, Social Security number, card number, IBAN, IP address and secret replaced by a typed placeholder, and the custom patterns of your content moderation guardrails masked too. Images are never read. The excerpt goes to a decision service run outside HIPS for the one call, and is never stored, logged or sent to a model's server; a masking that cannot finish within its bound sends nothing. A verdict and a conversation's model are kept under keyed hashes for a bounded time, never as text.

Docs: https://hips.com/docs/router


## For AI agents
- API: https://ai.hips.com/v1, OpenAI-compatible; the key is read from HIPS_API_KEY.
- Models: GET https://ai.hips.com/v1/models with the key, or https://hips.com/api/models without one.
- hi, the HIPS command line: curl -fsSL https://hips.com/hi.sh | sh, then hi models.
- Every page above as Markdown: its address plus .md (the home page at https://hips.com/index.md), or its address with Accept: text/markdown.
