Skip to content

How do I talk to KIplatz from my own code?

Through a door on your own device, in the OpenAI format. Whoever wants to go deeper runs everything in the sandbox. Here are the details the other pages only touch on, with examples you can copy.

A man explains a plan to a group at a whiteboard

The interface in five lines

Addresshttp://127.0.0.1:8470/v1, this PC only; a foreign Host header is refused
Keystarts with cai-, sent as Authorization: Bearer; "New key" invalidates the old one
EndpointsGET /v1/models, POST /v1/chat/completions with messages, stream, max_tokens
Limits40 messages, 60,000 characters, 256 kB, at most 1,500 tokens of answer; no images
Who answersalways your own PC or the paired one in your home network, never the community

Examples to copy: curl, Python, JavaScript

Key and model name are in the program under Settings, card "Other programs may ask KIplatz". Replace cai-YOUR-KEY with your key; the model name is unser-modell.

With curl, in one line

curl.exe http://127.0.0.1:8470/v1/chat/completions -H "Authorization: Bearer cai-YOUR-KEY" -H "Content-Type: application/json" -d "{\"model\": \"unser-modell\", \"messages\": [{\"role\": \"user\", \"content\": \"What is 3 times 9.90 euros?\"}]}"

With Python and the openai package

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8470/v1", api_key="cai-YOUR-KEY")
answer = client.chat.completions.create(
    model="unser-modell",
    messages=[{"role": "user", "content": "Summarise this text in 3 sentences: ..."}],
)
print(answer.choices[0].message.content)

With JavaScript, in the browser or in a script

const r = await fetch("http://127.0.0.1:8470/v1/chat/completions", {
  method: "POST",
  headers: { "Authorization": "Bearer cai-YOUR-KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ model: "unser-modell", messages: [{ role: "user", content: "What is an invoice number for?" }] }),
});
const data = await r.json();
console.log(data.choices[0].message.content);

With "stream": true the words arrive one by one as server-sent events, exactly as with OpenAI. Every request passes the house rules and gets the community's knowledge and your own knowledge added.

Switch on and connect

Under Settings, card "Other programs may ask KIplatz", you find address, model name and key. Every question passes the house rules and gets the community's knowledge and your own knowledge added.

Open WebUI, Jan, Continue, LibreChat and the Python package openai work without changes: enter base address and key, take over the model name. Nothing is stored as a conversation.

The sandbox

Start the program with --spielwiese: it uses its own data folder and the practice server (access "spielwiese"), never the real community.

The tests run with python -m pytest tests -q, all without network, without special hardware, without a real model; today more than 500 tests.

How the program is built

The ZIP contains a signed Python runtime (checksum fixed in the build script), packages only with a fixed version and SHA-256, our code and the start file as an unchanged copy of the Python launcher. The build runs a self-test without a window and stops at any error.

Updates: the program compares its build number with the server, fetches the ZIP, checks checksum and signature, replaces its folder (the old one stays for one start) and restarts.

The building blocks

Window via WebView2, open models and speech recognition on the device, skills in the Agent Skills format, home network with TLS 1.3 and its own device certificate.

The server is one Python service with mediation, knowledge store, distributor, collector and daily figures. Talk: Discourse. Build and sign-in: Forgejo, with OpenID Connect for the one account.

The protocol between device and server

A PC signs in with an identifier and a secret (the server keeps only a check value). Asking questions, fetching jobs, handing in results, collecting answers, reading the figures: all over https on its own port, with deadlines, upper limits and a brake per address.

A job never goes to the PC that asked; an answer comes only from the one that took the question, exactly once.

The recipe stays with KIplatz

As with a good recipe the ingredients are public, the mix stays with us: the wiki explains every part, sources and skills are open, and the program comes ready-built and signed from kiplatz.at.

What you find in Build: reports, ideas, questions and the guides for builders. Security issues please in confidence to support@kiplatz.at.

The door cannot be reached from the network.

Read on Help wanted · How safe it is · How KIplatz answers

Building starts with a report

Mistake, idea or question: three templates are waiting in the project KIplatz/mitbauen. The newest reports are on the start page.