Skip to main content

kiapi

License: MIT Python Platform API Docs

English | 日本語

Summary

kiapi is a local API server that uses Apple Silicon and MLX to provide generative AI capabilities for LLM agents.

API

Domain Family Endpoint Description
chat POST /v1/chat Chat API details
embedding POST /v1/embedding Embedding API details
image zimage POST /v1/image/zimage Z-Image API details
flux2 POST /v1/image/flux2 FLUX.2 API details
qwen POST /v1/image/qwen Qwen Image API details
ideogram4 POST /v1/image/ideogram4 Ideogram 4 API details
ernie POST /v1/image/ernie ERNIE-Image API details
seedvr2 POST /v1/image/seedvr2 SeedVR2 API details
depthpro POST /v1/image/depthpro Depth Pro API details
audio acestep POST /v1/audio/acestep ACE-Step API details
audiogen POST /v1/audio/audiogen AudioGen API details
video ltx2 POST /v1/video/ltx2 LTX-2 API details
web POST /v1/web Web API details
core files POST /v1/files Upload input files, LoRA adapters, and other files, then issue a file_id.
GET /v1/files Return a list of stored files.
GET /v1/files/{file_id} Return file metadata.
GET /v1/files/{file_id}/download Download the file body.
DELETE /v1/files/{file_id} Delete a stored file.
jobs GET /v1/jobs Return a list of generation jobs.
GET /v1/jobs/{job_id} Return job status, progress, result, and artifact file_ids.
DELETE /v1/jobs/{job_id} Remove a job from the job store. Running jobs are not interrupted.
openapi GET /openapi.json Return the common API and each capability documentation URL.
GET /v1/{domain}/{family}/openapi.json Return detailed input/output specs, usage, tips, and examples for each family.
health GET /health Return server status, warmup status, queue length, and memory usage.

See: kiapi API Docs

Requirements

  • macOS / Apple Silicon
  • Python >=3.12,<3.13
  • uv (optional, recommended for isolated CLI installs and faster venv/package setup in kiapi activate)
  • mise (used for development)
  • Docker (when using the Web capability)
  • Enough disk capacity for model weights and Docker images

kiapi is developed mainly for personal use on a Mac Studio M4 Max 128GB. Some or all features may work on other Apple Silicon environments, but they are not the primary verification target.

The memory budget can be specified with KIAPI_MEMORY_LIMIT_GB. If omitted, kiapi automatically uses 80% of installed memory as the effective budget on startup. If a model's required memory does not fit in that budget, requests return 503 as an insufficient memory budget error.

kiapi activate --all uses a little under 600GB of disk capacity, including model weights and Docker images. At first, it is recommended to use kiapi activate to set up only the capabilities you need.

Remote Job Relay

The optional GCP relay lets a kiapi node inside a closed network receive API work without exposing an inbound socket. Firebase Realtime Database carries small notifications, while Cloud Storage carries request and response bodies. Install kiapi with the relay-gcp extra to enable it:

python3.12 -m pip install --upgrade "kiapi[relay-gcp]"
uv tool install --python 3.12 "kiapi[relay-gcp]"
export KIAPI_RELAY_GCP_DATABASE_URL="https://PROJECT.firebaseio.com"
export KIAPI_RELAY_GCP_BUCKET="PRIVATE_RELAY_BUCKET"

# Uses Application Default Credentials by default.
kiapi run --relay gcp

Each node generates its own node_id on first start, persists it in the user data directory, and publishes a liveness heartbeat under liveness. A requester picks the most recently seen node and writes sessions/{session_id}/request.json in GCS, then writes a notification to nodes/{node_id}/requests/{session_id} in RTDB. The relay reports queued, running, and the terminal result below the requester node's responses path.

  • Requests are dispatched directly to the in-process FastAPI app and handled one at a time by the relay.
  • JSON responses use response.json. Binary responses write response.body before response.json.
  • response.json uses a GCS create-only generation precondition. A completed response found after restart is reported without executing the API again.
  • The terminal RTDB response and request deletion use one atomic multi-location update.
  • Startup installs a session-scoped lifecycle rule that deletes session objects after one day. Set KIAPI_RELAY_GCP_MANAGE_BUCKET_LIFECYCLE=false when infrastructure manages this rule.

Use a dedicated bucket and narrowly scoped RTDB/GCS permissions. Google credentials are configured through kiarina-lib-google.

See GCP Relay setup for resource creation, IAM, authentication, configuration, and verification steps.

For local relay verification without GCP, use local. It uses the same in-process dispatch path but stores notifications and payloads under a local directory:

export KIAPI_RELAY_LOCAL_ROOT="/tmp/kiapi/relay"
export KIAPI_RELAY_LOCAL_PREFIX="private/kiapi"

kiapi run --relay local

The requester writes {root}/{prefix}/sessions/{session_id}/request.json, then writes {root}/{prefix}/nodes/{node_id}/requests/{session_id}.json with {"session_id":"...","source_node_id":"..."}. The relay writes bridge status to {root}/{prefix}/nodes/{source_node_id}/responses/{session_id}.json and stores the committed response in the session directory.

Local Storage

kiapi mainly writes to these local paths at runtime.

Purpose Setting Default Notes
Files API uploads, generated artifacts, and URL/data URL inputs KIAPI_FILES_ROOT /tmp/kiapi/files Storage referenced by file_id. The default may disappear after OS reboot or tmp cleanup. Use ~/.kiapi/files or external storage for long-term retention.
Temporary working directories during request processing KIAPI_TMP_ROOT /tmp/kiapi/work Used for chat/embedding input expansion, generation intermediates, LoRA training work, and similar tasks.
Web backend subprocess logs KIAPI_WEB_BACKEND_LOG_DIR /tmp/kiapi/logs/web stdout/stderr for SearXNG / Crawl4AI Docker subprocesses.
ACE-Step dedicated venv / project / checkpoints KIAPI_ACESTEP_PYTHON_PATH, KIAPI_ACESTEP_PROJECT_ROOT, KIAPI_ACESTEP_CHECKPOINT_DIR acestep/ under the user data dir When python_path, project_root, and checkpoint_dir are omitted, kiapi places the ACE-Step venv and checkpoints under a persistent ACE-Step directory.

Other model weights and library caches are managed by Hugging Face, mflux, Docker, or each library/tool. kiapi generally does not move them into its own storage location.

Security

By default, kiapi run starts on 127.0.0.1:8000. When --host 0.0.0.0 is specified, the server may be reachable from other machines, so use it only on trusted networks.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiapi-0.5.0.tar.gz (261.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kiapi-0.5.0-py3-none-any.whl (470.1 kB view details)

Uploaded Python 3

File details

Details for the file kiapi-0.5.0.tar.gz.

File metadata

  • Download URL: kiapi-0.5.0.tar.gz
  • Upload date:
  • Size: 261.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiapi-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a7f45acf87fb75f586e69e80342debb5a073c6e413a4589b8578f5c70f1f88f5
MD5 d1596eceefe9bcdb0476ab228b69cd74
BLAKE2b-256 76cb9d5cf54a5f7d637fcb1b65f4ff62bbc7c1353459f13ffdcb64835250539a

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiapi-0.5.0.tar.gz:

Publisher: release-pypi.yml on kiarina/kiapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kiapi-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: kiapi-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 470.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiapi-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 978e54b9dc27e678fe255f6de55cadb667f44e068bee5811d19c24a7397afe50
MD5 0f974fe5473c42016a98b12e93cb6c62
BLAKE2b-256 9823d818da2be357ce23e42fbcd98ed72d2e0ae3e59697f37567d60238df8e9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiapi-0.5.0-py3-none-any.whl:

Publisher: release-pypi.yml on kiarina/kiapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

1 file

This release

0.5.0 This release

2 files

0.3.0

1 file

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page