Open source

Open-source backend runtime.
No lock-in. By construction.

Kirak is an open-source backend runtime. Declare your data model, auth, and access rules in JSON; Kirak serves the whole backend — REST & GraphQL APIs, authentication, row-level security, payments, storage, notifications, AI agents, and MCP servers — live from that declaration. Self-host it anywhere. No account, no key, no phone-home.

$pip install kirak
Apache 2.0
OSI-approved — fork, run, resell
Python 3.11+
Built on FastAPI
MySQL · Postgres · SQLite
Switch with one config line
Quickstart

Quickstart: a Kirak backend in about five minutes.

01

Install the runtime

Python 3.11 or newer.

terminal
pip install kirak
02

Scaffold a project

Creates main.py, kirak.json, a sample model in models/, hooks/, an AGENTS.md for coding agents, and JSON Schemas your editor picks up. The project's pyproject.toml pulls in the database driver.

terminal
kirak new my-backend --database postgres   # or mysql, or sqlite
cd my-backend
pip install -e .
cp .env.example .env   # secrets only: DB password + JWT keys
03

Declare a model

One file per model: its fields and access rules in models/note.json. Run kirak validate to check it.

models/note.json
{
  "schema": {
    "title": {"type":"string","required":true},
    "body": {"type":"text"},
    "owner_id": {"type":"integer","required":true}
  },
  "access": {
    "fetch":  [{"role":"user","condition":"owner_id = {user_id}"}],
    "create": [{"role":"user","condition":"owner_id = {user_id}"}]
  }
}
04

Run it

Applies the schema to your database, then starts serving on :8000.

terminal
kirak db init
uvicorn main:app --reload
05

Call the API

Full CRUD on /note, access-filtered to the authenticated user by owner_id.

terminal
curl -X POST localhost:8000/note/create \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"title":"first","body":"hello"}}'
06

Put it online with Kirak Deploy

Run kirak deploy in the project folder and the API is live on Kirak's hosting, with a public URL — no account required. The instance is temporary until you claim it, which keeps it running on the free tier. How Kirak Deploy works →

terminal
kirak deploy
Deployed: https://<random-name>.kirak.dev
Claim URL: https://...
In the runtime

Kirak features: everything a production backend needs. In the open-source release.

Blue layers are served automatically from your declaration; amber is the one layer where you write real Python you own. Coding-agent tooling is set apart at the end.

Served by the runtime

Model-driven REST & GraphQL API

Every model file in models/ becomes a documented endpoint set — list, search, count, create, update, upsert, soft delete and restore, hard delete — with filtering, pagination, sorting, per-model rate limits, and before/after hooks on every operation. The same operations are served over a shared GraphQL endpoint, under the same access rules. Change a field and the API changes with it.

FastAPI · Pydantic · OpenAPI 3.1 and a Markdown reference for AI agents, generated and kept in sync
$ uvicorn main:app  ·  served from models/booking.json
/booking10 endpoints
GET/booking/fetchlist + filter + paginate
GET/booking/searchfull-text search
GET/booking/countcount matching rows
GET/booking/existsdoes a match exist?
POST/booking/createvalidate + create
PUT/booking/updateupdate, filtered by "where"
PUT/booking/upsertinsert or update
DELETE/booking/deletesoft delete, with "soft_delete": true
PATCH/booking/restoreundo a soft delete
DELETE/booking/destroyhard delete
/graphql1 endpoint
POST/graphqlqueries, mutations, aggregates · same access rules
/docs · /openapi.json2 endpoints
GET/docsMarkdown API reference, written for AI agents
GET/openapi.jsonOpenAPI 3.1, always in sync
Served by the runtime

Row- & field-level security

Per-role access rules declared as an access block in each model file, enforced at the query level on every list, read, and join — for every role. Field rules go further: hide a column from some roles, or make it read-only. Declarative, not a bolt-on policy language you maintain separately.

Enforced identically on REST, GraphQL, MCP tools, agent tools, and your hooks
models/booking.json
"access": {
  "fetch":  [
    {"role":"admin"},
    {"role":"user", "condition":"renter_id = {user_id}"}
  ],
  "create": [{"role":"user"}],
  "update": [{"role":"user", "condition":"renter_id = {user_id}"}],
  "destroy": [{"role":"admin"}],
  "fields": {
    "internal_notes": { "read": ["admin"], "write": ["admin"] }
  }
}
Real code you own

Hooks & custom endpoints

The one place you write real code. Business logic that isn't plain CRUD runs as before/after hooks on every operation, or as fully custom endpoints beyond the generated set. Sync hooks are blocking: they work like a pipeline — each takes the request, modifies it, and feeds it to the next hook or the operation, and raising an error stops the request with a clean 4xx.

Async hooks are non-blocking: a failure or timeout is logged and skipped, so they suit side effects like notifications that must never fail the request. Real Python/FastAPI — scaffolded for you, committed to your own repo, surviving every later declaration change. It runs inside the runtime's access rules, so you extend the backend without opening a hole in it.

Python 3.11+ · FastAPI · no DSL, no proprietary abstraction
hooks/booking.py — yours to keep
# registered inside on_kirak_ready(kirak)

# sync hooks are a blocking pipeline: each takes the request, modifies it,
# and feeds it to the next hook or the operation -- raise to stop it
@kirak.on("booking").hook("before_create")
def check_dates(payload):
    data = payload["data"]
    if data["ends_at"] <= data["starts_at"]:
        raise ValidationError("ends_at must be after starts_at")  # 400
    return payload

@kirak.on("booking").hook("before_create")
def apply_deposit(payload):    # runs next, on check_dates' output
    payload["data"]["deposit_cents"] = payload["data"]["total_cents"] * 20 // 100
    return payload

# async hooks are non-blocking: a failure or timeout is logged
# and skipped -- it never fails the request
@kirak.on("booking").hook("after_create")
async def notify_owner(result):
    await kirak.notifications.send_im({"to": OWNER_CHANNEL, "text": "New booking"})
    return result
Served by the runtime

Authentication

MFA, passwordless SMS one-time codes, API keys, and email verification are built directly into Kirak Auth — Kirak's own build on JWT sessions with refresh-token rotation, not bolted on from a third-party library. Social / OAuth login is powered separately by Social Core, covering 200+ provider backends.

GoogleGitHubAppleMicrosoftLinkedInDiscord+ 200 more
MFA, OTP, and API keys are Kirak's own build · passkeys & SSO are on the roadmap
POST/auth/registeremail + password
POST/auth/login+ mfa_code in the same call
POST/auth/logoutend the session; the access token lasts until it expires
GET/auth/mecurrent authenticated user
POST/auth/refresh-tokenrotates access + refresh
POST/auth/request-reset-password+ /reset-password
POST/auth/request-otp+ /verify-otp · passwordless SMS code
POST/auth/api-keys/createserver-to-server key · X-API-Key
GET/auth/{provider}/loginsocial login redirect
Served by the runtime

Payments

Checkout, one-off charges, subscriptions (cancel, change, pause, resume), refunds, saved cards and off-session charges, disputes, and Stripe Connect marketplace payouts — with webhook verification and reconciliation wired up, served by the runtime, not a hook you maintain. Run several gateways side by side as named providers; amounts are handled in each currency's minor unit. Provisioning logic lives in an after_webhook hook when you need it.

StripePayPalPaddleRazorpaySquarePaystackFlutterwaveMercado PagoXenditAirwallexOmiseTelr
Webhook signature checks, replay protection, dedup, and idempotency keys handled by the runtime
POST/payments/initiatecheckout, or a subscription
POST/payments/webhook/{service}provider callback · signature-verified
POST/payments/connect/onboardStripe Connect merchant onboarding
POST/payments/connect/checkoutmarketplace checkout + platform fee
POST/payments/methods/setupsave a card for later
GET/payments/methodsthe caller's saved methods
GET/payments/providersconfigured gateways + what each supports
Served by the runtime

Storage

File and image upload with automatic image compression and thumbnail generation. Declare an upload field and the runtime handles multipart parsing, validation, and the storage backend — local disk or any of nine object stores, several at once as named providers.

Local diskAmazon S3Cloudflare R2Google Cloud StorageAzure BlobDigitalOcean SpacesBackblaze B2WasabiOVHcloudCubbit
Backend switched in kirak.json — no code change
POST/storage/upload/imagemultipart, with compression + thumbnails
POST/storage/upload/filemultipart, non-image
GET/storage/urlpublic or presigned URL
DELETE/storage/deleteremove object, optionally + thumbnails
Served by the runtime

Notifications

Email, SMS, push, instant messages to Slack, Discord, or Telegram, signed outgoing webhooks, and an in-app notification inbox, each with its own send method — delivery, templates, and per-user preference checks are runtime concerns; you call kirak.notifications from a hook or route.

SESSendGridSMTPSNSTwilioFirebaseAPNsHuawei PushSlackDiscordTelegramWebhooks
Provider chosen per channel in kirak.json
GET/notifications/inboxin-app inbox · paginated
PUT/notifications/inbox/{id}/readmark read
POST/notifications/send-multiseveral channels in one call
POST/notifications/send-imSlack · Discord · Telegram
POST/notifications/send-webhooksigned outgoing webhook
GET/notifications/preferencesper-user channel opt-in
Served by the runtime

Integrations

Let your users connect their own third-party accounts, through OAuth2 or API keys. Kirak encrypts the tokens with AES-GCM, refreshes them automatically, hands your code a ready client for API calls, and stores and retries incoming webhooks. Pick from ready-made profiles or define your own without touching Kirak.

HubSpotGitHubSalesforceSlackAirtable+ 107 more
Tokens encrypted at rest · refresh and webhook retries handled by the runtime
GET/integrationsthe integrations available
POST/integrations/{name}/connectstart an OAuth connection
GET/integrations/connectionsthe caller's connections
PUT/integrations/{name}/keysave an API key
POST/integrations/{name}/connections/{id}/checktest a connection
DELETE/integrations/{name}/connections/{id}disconnect
POST/integrations/{name}/webhooksincoming webhooks, stored and retried
Served by the runtime

Scheduler

Background job queue and cron scheduler with zero extra infrastructure by default — DB-backed out of the box. Register a job with a decorator, or create schedules at runtime over HTTP; the runtime handles timing, retries with backoff, timeouts, crash recovery, and history. Route queues to several backends at once, or run in serverless tick mode.

DB-backedRedisRabbitMQ
DB-backed default · Redis and RabbitMQ backends for scale, side by side
POST/scheduler/enqueueenqueue a job over HTTP
GET/scheduler/jobsrecent jobs + status
GET/scheduler/registeredregistered tasks + cron expressions
DELETE/scheduler/jobs/{job_id}cancel a pending job
POST/scheduler/schedulescreate a cron schedule at runtime
POST/scheduler/schedules/{id}/runrun a schedule now
Served by the runtime

Caching

Native Redis query caching: switch it on for every model in kirak.json, or per model in its own file. The runtime keys each entry by what the caller is allowed to see, invalidates on write, and serves reads from cache — no cache code in your project.

Redis
Redis — invalidation handled on every create / update / delete
// default for every model
"cache": {
  "enabled": true,
  "default_ttl_seconds": 60
}
Served by the runtime

Rate limiting

Global limits and per-model overrides, with Redis or database-backed counters and standard rate-limit headers. Declared, not coded.

RedisDB-backed counters
Over the limit: 429 with a Retry-After header
// default for every route
"rate_limit": {
  "enabled": true,
  "default_max_requests": 100,
  "default_window_seconds": 60
}
Served by the runtime

AI agents

Declare agents in agents/*.json: a model, instructions, and the tools they may use — CRUD on your models, a module's operations, or whole MCP servers. For anything custom, register a Python function with @kirak.agent("name").tool, the same way you write a hook. Every tool call runs as the caller, under your access rules, and each agent sets who may run it and a per-caller rate limit. Mark a tool requires_confirmation and the run pauses for a human to approve it.

Multi-turn conversations with automatic compaction, cost caps, goal-driven runs checked by a reviewer model, streaming, structured output, and a full run history are built in — with model, tokens, cost, and tool calls recorded by monitoring.

Built on pydantic-ai — so any model pydantic-ai supports works, not a fixed provider list: OpenAI, Anthropic, Gemini, OpenRouter, and more.

OpenAIAnthropicGeminiOpenRouter+ any pydantic-ai model
POST/ai/promptone-shot generation, optional structured output
GET/ai/agentsdeclared agents
POST/ai/agents/{name}/runrun an agent · streaming
POST/ai/agents/{name}/resumecontinue after human approval
GET/ai/agent/runsrun history, with tool calls + cost
Served by the runtime

MCP servers

Declare an MCP server per audience — an admin server for an internal agent, a support server for a customer-facing one, one for a UI builder — each a JSON file in mcp/ with its own toolkit: the operations it offers as tools, who may connect, and a rate limit. Add Python tools to a server with @kirak.mcp("support").tool. Any MCP client can connect; every tool call runs as the caller, under your access rules. Nothing is exposed until you declare it.

Streamable HTTP at /mcp/<name>/ · bearer token or API key · calls per server and tool recorded by monitoring
{
  "name": "support",
  "description": "Order lookups for the support team",
  "access": "User",
  "rate_limit_per_minute": 60,
  "tools": {
    "orders.fetch": {},
    "orders.search": {},
    "orders.update": { "timeout": 10 }
  }
}
Served by the runtime

Vector & RAG

Vector stores and embeddings for retrieval-augmented generation: create indexes, upsert text or vectors, and search with metadata filters. Agents use it as a tool, so the agent decides when to retrieve — there's no fixed pipeline to maintain. No public HTTP endpoints by design — call it from your own routes, hooks, and agents under your access rules.

PineconeS3 VectorsEmbeddings:OpenAIGeminiOllama
Stores and embedding providers configured independently in kirak.json
kirak.vector — in any hook, route, or agent tool
await kirak.vector.upsert({
    "index": "docs",
    "vectors": [{"id": "faq-1", "text": "Refunds take 5 days."}],
})

result = await kirak.vector.search({
    "index": "docs",
    "text": "How long do refunds take?",
    "top_k": 5,
})
Built for coding agents

An agent-ready project

A Kirak project is mostly JSON, so a coding agent needs facts it can't guess and a way to know its edit is valid. kirak new writes an AGENTS.md and JSON Schemas for every file; kirak validate checks each edit before the app starts; kirak catalog --json and friends report modules, providers, settings, and secrets for the installed version; kirak dev mcp serves all of it to the agent over MCP; GET /docs describes the running API in Markdown; and the Agent Kit plugins teach the agent how to use it all.

Claude CodeCursorCodex
The rule for an agent: ask the CLI instead of guessing, and validate after every edit — read the guide
terminal
kirak validate                   # models, kirak.json, agents, MCP servers
kirak catalog --json             # every module, provider, and setting
kirak providers payments --json  # settings + secrets for each gateway
kirak env                        # the secrets this project needs
kirak dev mcp                    # all of the above, over MCP
Served by the runtime

Monitoring

Application performance data, structured logs, error tracking, per-request tracing, audit records, AI run costs, and MCP tool calls — opt-in module, the instrumentation lives in the runtime itself, so you can see into a Kirak backend without bolting on a third-party APM.

Studio adds a dashboard, trace explorer, and alerts on top of this data
GET  ·  runtime instrumentation
GET/monitoring/pingliveness, no auth
GET/monitoring/healthstore health + queue depth
GET/monitoring/metricsOpenMetrics format
GET/monitoring/trace/{request_id}full request timeline
GET/monitoring/requests/timeseriestraffic + latency over time
GET/monitoring/ai/summaryAI runs, tokens, cost
GET/monitoring/mcp/summaryMCP calls per server + tool
POST/monitoring/alerts/evaluatethreshold checks for alerting
MySQLPostgreSQLSQLite

Database-agnostic

PostgreSQL, MySQL, or SQLite, switched with one line — "database": {"type": "postgres"} in kirak.json — not tied to a single vendor.

SOC 2

Built for SOC 2 reviews

Security controls built to help the APIs you serve pass a SOC 2 review.

No lock-in

Modular & portable

Lazy-loaded, so nothing ships unless you enable it. Self-host it on your own database, anywhere you run Python.

Front-end SDKs

Kirak front-end SDKs for TypeScript, React and Flutter.

Official client SDKs for calling a Kirak backend from your app — sign-in and sessions handled for you, so your UI code only talks about your data.

TypeScript / JavaScript

The core client for any JavaScript runtime — the browser, Node.js, and React Native.

npm install kirak
View on npm →

React

React bindings for the Kirak client, for using your backend from React components.

npm install kirak-react
View on npm →

Flutter

The Dart and Flutter client — sign-in sessions persisted and restored across app starts.

flutter pub add kirak_flutter
View on pub.dev →
Kirak Dev MCP

Kirak Dev MCP: a coding-agent server for your project. Facts, checks, and live debugging.

kirak dev mcp is a local MCP server for the agent writing your backend. Your coding tool starts it in the project folder; it opens no port, needs no credentials, and every tool is read-only. Instead of guessing at Kirak, the agent asks.

Know the project

Facts for the installed version, not from memory.

The agent can read the project — Kirak version, enabled modules, models, agents, migrations — and look up every module, provider, setting, and secret the installed Kirak supports. It fetches the JSON Schema for any file it's about to write, and validates a draft before saving it, so a bad edit never reaches the running app. Migration status and a dry-run preview tell it what a schema change will do to the database.

Each tool returns the same JSON as the matching kirak command's --json
kirak dev mcp  ·  project tools
kirak_project_info       # version, modules, models, agents
kirak_catalog            # modules, providers, settings, secrets
kirak_schema             # JSON Schema for any Kirak file
kirak_validate           # check a draft before it's written
kirak_env                # the secrets this project needs
kirak_migration_status   # applied and pending migrations
kirak_migration_preview  # what the next migration would do
See what the app did

Debug from evidence, not print statements.

Live tools show the agent what your running app has been doing: recent errors with tracebacks and the request that failed, recent requests filtered by status or route, a full trace of any one request through its hooks, database, and provider calls, and recent AI agent runs with their tokens, cost, and tool calls. They read the files the app writes, so they still answer after it has crashed. And the agent can read the app's own /docs before building a front end against it.

Richest with the monitoring module on in development; falls back to kirak.log
kirak dev mcp  ·  live tools  ·  .mcp.json
kirak_recent_errors       # tracebacks + the failing request
kirak_recent_requests     # filter by 5xx, 404, route, slowest
kirak_request_trace       # hooks, db, provider calls, timings
kirak_recent_agent_runs   # model, tokens, cost, tool calls
kirak_api_docs            # the running app's GET /docs

// .mcp.json (Claude Code) — same command in any tool
{ "mcpServers": { "kirak": {
  "command": "uv", "args": ["run", "kirak", "dev", "mcp"]
} } }
$pip install "kirak[dev-mcp]"
Kirak Agent Kit

Kirak Agent Kit for Claude Code, Cursor and Codex. Plugins that teach your tool to build the Kirak way.

The Dev MCP gives an agent the facts. The Agent Kit gives it the judgment: a plugin for each major coding tool with skills, guardrails, and hooks written by the people who build Kirak. It never holds its own copy of a Kirak fact — it tells the agent to ask the project's kirak, so the answers always match your installed version.

Skills

How to design models and access rules, choose between configuration, hooks, routes, and modules, pick providers, write AI agents, run migrations, debug, and build a front end against GET /docs.

Guardrails

Kirak first: data only through Kirak's model layer, never raw SQL; a provider before any integration code; settings in kirak.json and only secrets in .env; every model secured with an access block.

Hooks, commands & review

Where the tool supports them: validate after every edit of a Kirak file, remind about migrations, guard destructive commands — plus commands to scaffold a model, check project status, and review changes.

Claude CodeCodexCursorGitHub CopilotGoogle Antigravity
claude ›/plugin marketplace add kirak-io/kirak-agent-kit

Then /plugin install kirak@kirak. Install steps for every tool are in the repository.

License

Apache License 2.0. Genuine open source.

OSI-approved. No license-level restriction on commercial use, forking, or offering Kirak as a competing hosted service.

What you can do

Copy, modify, distribute, and run Kirak for any purpose — including building a commercial product or a hosted service on top of it.

Patent grant + retaliation

Contributors grant a patent license for their contributions; anyone who sues over patent infringement loses their license to use the software.

Trademark

The license grants no right to the Kirak name or marks. A fork can rename and rebrand freely, but can't call itself "Kirak" or imply endorsement.

A fork must preserve copyright and attribution notices in the source and mark modified files as changed — it has no obligation to keep the Kirak name or credit Kirak in marketing. That's the deliberate trade-off of Apache 2.0 over a source-available license.

Community

Contributing & getting help.

GitHub Discussions

Questions, ideas, and design discussion — indexable and searchable, the durable record.

Open Discussions →

Discord

Real-time help and build-along chat with the team and other developers.

Join the Discord →

Contributing

Read CONTRIBUTING.md first — it covers the PR process and the policy on AI-generated contributions.

Read the guide →

Declare your backend. Run it yourself.

Ask about Kirak on