Examples
April 6, 2026 ยท View on GitHub
Small, runnable samples that talk to localaik on http://localhost:8090. Use them to sanity-check your setup or as templates for your own code.
Prerequisites
-
Start localaik (pick one):
docker run -d -p 8090:8090 gokhalh/localaikOr from the repo root:
make docker-up(defaults to port18090โ setPORT=8090if you want the examples unchanged). -
Wait until the model is loaded (
GET /healthreturns 200). The first start can take a while. -
Run an example from the directory listed below (each folder has its own dependencies).
Python 3
- The python/ samples need Python 3 and the listed SDK packages (
google-genai, OpenAI client, etc.). - The curl/ scripts are shell +
curl, but they pipe the response throughpython3 -m json.toolso the JSON is pretty-printed. Install Python 3 on your PATH, or remove the| python3 -m json.toolsuffix and read raw JSON instead.
Layout
| Language | Gemini | OpenAI | Structured output (Gemini) |
|---|---|---|---|
| curl | curl/gemini.sh | curl/openai.sh | curl/gemini-structured.sh |
| Go | go/gemini | go/openai | go/gemini-structured |
| Python | python/gemini | python/openai | python/gemini-structured |
| JavaScript | javascript/gemini | javascript/openai | javascript/gemini-structured |
| Java | java/gemini | java/openai | java/gemini-structured |
Conventions
- Base URL:
http://localhost:8090for Gemini-style calls; OpenAI clients usehttp://localhost:8090/v1. - API key: Examples use a placeholder such as
testwhere the SDK requires one; localaik does not validate keys. - Model name: Samples use
localaikas the model id where applicable; the proxy forwards to the bundled upstream model.
Dependencies
Examples do not share a single lockfile. Install what you need per language (e.g. google-genai for Python, google.golang.org/genai for Go, official OpenAI packages for OpenAI examples). curl-only: aside from optional python3 for JSON formatting (see above), no extra installs.