Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 2.99 KB

README.md

File metadata and controls

44 lines (28 loc) · 2.99 KB

Examples

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

Language Gemini OpenAI Anthropic Structured output (Gemini)
curl curl/gemini.sh curl/openai.sh curl/anthropic.sh curl/gemini-structured.sh
Go go/gemini go/openai go/anthropic go/gemini-structured
Python python/gemini python/openai not yet python/gemini-structured
JavaScript javascript/gemini javascript/openai not yet javascript/gemini-structured
Java java/gemini java/openai not yet java/gemini-structured

PDF parsing: go/gemini-pdf sends a fake invoice PDF through Gemini and extracts its fields as structured JSON. It ships an embedded sample, so go run main.go works with no setup; pass a path to use your own PDF.

Conventions

  • Base URL: http://localhost:8090 for Gemini-style calls; OpenAI clients use http://localhost:8090/v1; Anthropic clients use http://localhost:8090 (their SDKs append v1/ themselves).
  • 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.