---
artifact_id: ao-idlehw-openai-compatible-servers-code
kind: code-snippet
slug: ao-idlehw-openai-compatible-servers
iil_id: null
note_url: https://iinventedlight.com/library/notes/ao-idlehw-openai-compatible-servers/
title: "Illustration: one OpenAI client, two local servers"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
as_of: 2026-11-16
status: week-draft-20261116
untested: "Not executed (no local model server on the box). Ports are the usual defaults; check your server flags."
related_slugs:
  - ao-idlehw-openai-compatible-servers
  - ao-idlehw
source_notices: >
  The note cites MIT (ggml-org/llama.cpp (GitHub)); Apache-2.0 (vllm-project/vllm (GitHub)); prose restates cited source lines in own words. This snippet is an original illustration, not a copy of a docs example.
---

# Illustration for ao-idlehw-openai-compatible-servers (round-1 draft, not live yet)

The round-1 note: llama-server and vLLM both expose `/v1/chat/completions`. vLLM `--api-key` does not protect every path, so keep these servers behind a reverse proxy.

```python
from openai import OpenAI

# llama.cpp llama-server (default port 8080) or vLLM (default port 8000)
client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="local-dev-key")

resp = client.chat.completions.create(
    model="served-model-name",
    messages=[{"role": "user", "content": "Say hi in three words."}],
)
print(resp.choices[0].message.content)
```

This file is a local draft for the 16 November week. It is not live.
