# Your machine as a model server

> **What you will learn**
> What "`/api/ai` is OpenAI compatible" means in practice — what you change and
> what you leave alone.
>
> **If SDKs or Python are unfamiliar,** start with [Programs and languages](/guide/it-programs).

## In one line

> **Change the base address on an OpenAI SDK and your own machine's models
> answer.**

The code stays. The library stays.

## You change two lines

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:27777/api/ai/v1",   # ← this line
    api_key="<dashboard password>",                 # ← this line
)

r = client.chat.completions.create(
    model="...",
    messages=[{"role": "user", "content": "Hello"}],
)
```

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:27777/api/ai/v1",
  apiKey: process.env.HT_KEY,
});
```

**Nothing else changes.** Streaming, function calling, your existing code — all
as-is.

![The MCP tab in HyperTe](/guide-assets/ht-mcp.png)

The MCP tab in HyperTeams. This is where you see which tools this machine exposes.

## What opens

The list `inference` mode opens, from
[the API surfaces chapter](/guide/ht-api-surfaces).

| Kind | Path |
|---|---|
| List | `/v1/models` |
| **Chat** | `/v1/chat/completions` |
| Completions | `/v1/completions` |
| **Embeddings** | `/v1/embeddings` |
| Moderation | `/v1/moderations` |
| **Speech → text** | `/v1/audio/transcriptions` |
| **Text → speech** | `/v1/audio/speech` |
| Audio classification | `/v1/audio/classification` |
| **Image generation** | `/v1/images/generations` |
| Image editing | `/v1/images/inpainting` |
| Upscaling | `/v1/images/upscale` |

Audio and images get [their own chapter](/guide/ht-voice-image).

## Why this is useful

### 1. Switching becomes nearly free

```mermaid
graph TD
  A["Your application"] --> B["OpenAI SDK"]
  B --> C1["Commercial API"]
  B --> C2["Your machine · HyperTeams"]
  C1 -.->|"one line of base address"| C2
```

Develop against local models and run on a commercial API, or the reverse.
**Configuration, not a code branch.**

### 2. Data that must not leave

Run processing that touches customer data or unreleased material on local
models. It is the strongest form of
[things to watch out for](/guide/ai-cautions) saying "use a work environment for
work" — **it does not leave at all.**

### 3. Repeated cost

Calls that repeat in bulk — embeddings, classification — cost nothing per item
locally. Where quality is sufficient, the difference is large.

### 4. Benchmarking

Compare models by changing only the base address in the same code. **Measuring
which model fits your data** yourself is the most reliable answer.

## Which work suits local models

| Work | Local suitability |
|---|---|
| Classification, tagging | **high** — repetitive and undemanding |
| Embeddings | **high** — bulk processing |
| Summarising (short) | high |
| Speech recognition and synthesis | **high** — see the next chapter |
| Long-document reasoning | medium — depends on model and hardware |
| Complex code writing | low — commercial models lead |

**This is [model routing](/guide/ha-guardrails) locally.** Match by difficulty as
before, except now there is one more option: your own machine.

## Where it fails

### Model names differ

Using a commercial API's model name gets you nothing. **Check the list first.**

```bash
curl -H "Authorization: Bearer $HT_KEY" \
  http://localhost:27777/api/ai/v1/models
```

### Response times differ

Depending on hardware it can be much slower. Timeouts tuned for a commercial API
will fail as-is. **Measure once and leave headroom.**

### Calling yourself is blocked

Get the address wrong so the dashboard calls itself and you are cut off with a
**`508`**. That is not a bug but a loop guard — without it, sockets pile up at
every hop. A `508` means **check whether the address is your own dashboard.**

### Calling management paths under `inference`

Downloading a model or restarting the server returns **404** under `inference`.
Confirm the action you need really is a management path, and if so you need
`full` — which is
[granting that program management over your model server](/guide/ht-api-surfaces).

## The two base addresses, again

| What you are attaching | base |
|---|---|
| OpenAI-compatible SDKs and tools | `…/api/ai/v1` |
| Another HyperTeams dashboard | `…/api/ai` |

**With an SDK it is the first one.** The SDK does not append `/v1` for you, so it
has to be in the base.

## Common questions

### "So we don't need the commercial API any more?"

No. **Different work suits different options.** Split what local is good at
(repetitive, bulk, leak-sensitive) from what commercial is good at (hard
reasoning, long context). OpenAI compatibility means **mixing the two is cheap.**

### "My machine isn't powerful."

Start with what small models handle — classification, tagging, embeddings. These
do not need a large model. Send only the hard parts to a commercial API.

### "Can I open it to my team?"

Open a [tunnel](/guide/ht-remote-access). But at that moment **one key also opens
your dashboard.** If the goal is sharing models across a team,
[Connect](/guide/cn-what-is-it) is the better fit for permission management.

---

## Check yourself

**1. What do you change in existing code?**

<details>
<summary>Answer</summary>

**The base address and the key — two lines.** Because it is OpenAI compatible,
the SDK, streaming, and function-calling code stay as they are.
</details>

**2. What should you suspect on a `508`?**

<details>
<summary>Answer</summary>

**That the address is your own dashboard.** It detected a loop of the dashboard
calling itself and cut it; without that, sockets pile up at every hop.
</details>

**3. Which kinds of work suit local models especially well?**

<details>
<summary>Answer</summary>

**Repetitive, undemanding work like classification, tagging and embeddings**, and
**data that must not leave.** Hard reasoning and complex code writing still
favour commercial models.
</details>

---

Audio and images behave differently, so they get their own chapter →
[Working with audio and images](/guide/ht-voice-image)
