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

  1. Start localaik (pick one):

    docker run -d -p 8090:8090 gokhalh/localaik
    

    Or from the repo root: make docker-up (defaults to port 18090 โ€” set PORT=8090 if you want the examples unchanged).

  2. Wait until the model is loaded (GET /health returns 200). The first start can take a while.

  3. 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 through python3 -m json.tool so the JSON is pretty-printed. Install Python 3 on your PATH, or remove the | python3 -m json.tool suffix and read raw JSON instead.

Layout

LanguageGeminiOpenAIStructured output (Gemini)
curlcurl/gemini.shcurl/openai.shcurl/gemini-structured.sh
Gogo/geminigo/openaigo/gemini-structured
Pythonpython/geminipython/openaipython/gemini-structured
JavaScriptjavascript/geminijavascript/openaijavascript/gemini-structured
Javajava/geminijava/openaijava/gemini-structured

Conventions

  • Base URL: http://localhost:8090 for Gemini-style calls; OpenAI clients use http://localhost:8090/v1.
  • API key: Examples use a placeholder such as test where the SDK requires one; localaik does not validate keys.
  • Model name: Samples use localaik as 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.