kedi
Natural language, made programmable.
A typed orchestration language for LLM programs.
Website · Documentation · Examples · Discord
In Kedi, a sentence can define a model interaction and the typed values it produces. Those values become inputs to the rest of your program: another template, a Python function, a branch, or a remote agent.
The language owns that composition. Python handles ordinary computation;
models and agent SDKs connect through the AgentAdapter boundary.
A Sentence Becomes a Value
Kedi · main.kedi
~Action(task: str, owner: str | None, deadline: str | None)
@extract_actions(notes: str) -> list[Action]:
>> Extract agreed, unfinished work from <notes>.
Use null for owners or deadlines that were not stated.
The action items are [actions: list[Action]].
= `actions`
= `extract_actions("Sam will add tests by Friday. The redesign is only a suggestion.")`
<notes> supplies the input. [actions: list[Action]] declares a capture.
actions then holds a validated list of Action objects, not text to parse later.
The model sees the capture inside the sentence that gives it meaning, alongside
the output schema. = returns the value from the procedure or program.
| Written once | Used throughout the program |
|---|---|
| A typed capture | Model-visible context, output schema, and a typed binding |
| A procedure | Reusable logic, a Python-callable function, or an agent tool |
| An agent profile | Lexically scoped model, instructions, tools, and child agents |
Type validation checks structure, not the factual truth of a model's answer.
Try It
Install the released package:
pip install kedi
The examples below live in the repository. Clone it to run them against the current source, including its parser:
git clone --recurse-submodules https://github.com/kedi-lang/kedi.git
cd kedi
uv sync --locked --dev
source .venv/bin/activate
export KEDI_ADAPTER=pydantic
export KEDI_ADAPTER_MODEL=openai:gpt-6-luna
kedi examples/meeting_actions/main.kedi
Set OPENAI_API_KEY in your environment or the checkout's .env before running
the final command. Never commit credentials. To try Kedi without a model or
API key, run kedi examples/module_imports/main.kedi instead.
Already using Codex? See subscription authentication.
On Windows, use .venv\Scripts\Activate.ps1 and PowerShell environment syntax.
The installation guide
covers package installs; the PyPI badge reports the published release, which may
lag the source examples.
Program in the Terminal
kedi --idle brings the language into a live session, with syntax highlighting
on by default. Write templates, inspect typed captures, call procedures, and
mix in Python without creating a file. Bindings stay available between inputs.
Try a template and inspect its result
$ kedi --idle
+++ [country] = Sweden
+++ >> The capital of <country> is [capital: str].
+++ :show <capital>
Stockholm
+++ :show `capital.upper()`
STOCKHOLM
Kedi and embedded Python are both highlighted as you type. Use :multiline to
compose a larger fragment, :show to inspect a value, and :dump to save the
session. Resume it later with kedi --idle --load PATH, or start with --record
to save on exit. No language server is needed.
Prefer plain input? Run kedi --idle --no-color.
Explore the terminal REPL.
Let the Program Carry the Workflow
Conditions can ask a model a question. Loops, assignments, and returns remain ordinary program control flow. Here, only user-visible changes become release notes.
Kedi · model-classified conditions and native loops
@release_notes(changes: list[str]) -> list[str]:
[notes: list[str]] = `[]`
> loop [change]: `changes`:
> if: The text "<change>" describes a user-visible change, not internal maintenance
>> Describe <change> without inventing new benefits.
The one-sentence release note is [note: str].
[notes] := `notes + [note]`
= `notes`
= `release_notes(["CSV exports now preserve accents.", "Renamed a test fixture."])`
Use a Python condition such as > if: `count > 0`: for a deterministic
branch. Attach > map: to a loop to process each iteration's outputs as they
resolve. Independent template calls run
concurrently by default; dependent calls wait for their inputs. Calls sharing
a conversation retain their turn order.
Control flow · Runnable release-notes workflow
Give Agents a Scope, Then Compose Them
A profile is part of the program, not a global client configuration. Procedures capture their lexical configuration. Tools and subagents are explicitly made available to the profiles that need them.
Kedi · one coordinator, two scoped reviewers
> profile: security:
> instructions: Look for missing authorization checks in the supplied change.
> profile: reliability:
> instructions: Look for failure handling and cleanup problems in the supplied change.
> profile: coordinator:
> subagent: security
> subagent: reliability
> max_agents: 2
> use: coordinator
[change] = A new endpoint exports every account's data and closes its connection only on success.
>> Have security and reliability review <change>, each within its own scope.
Based on both reviews, the release recommendation is [recommendation: str].
= <recommendation>
The template runs with coordinator, which receives a delegate_task tool for
its two declared children. Each child reviews the supplied change under its own
system instruction; the coordinator combines their findings into the typed
recommendation. For program-directed orchestration, use > task and > await
to start and collect child work explicitly, without a coordinator model call.
Profiles · Task and await · A real procedure exposed as a tool
Let Jev Make the Decision
Not every model interaction needs generated prose. With TypeSafe's Jev, Kedi can request finite choices, boolean decisions, probabilities, and rubric scores, then use those values in the same program.
Kedi · route a support request with an explicit escalation criterion
> import: decisions
> model: typesafe/jev-latest
> settings:
typesafe_threshold: 0.85
~Triage(
team: Literal["billing", "access", "general"],
urgent: Annotated[
bool,
"Does the request need immediate intervention?",
`BooleanCriteria(true="Ongoing harm", false="Resolved, hypothetical, or informational")`
]
)
>> A customer says: "My card is still being charged every hour for the same invoice."
The routing decision for this request is [triage: Triage].
> if: `triage.urgent`:
= Escalate to <`triage.team`>.
> else:
= Queue for <`triage.team`>.
The threshold controls the boolean, not the category choice. The branch reads the already computed value; it does not ask another model to reinterpret it. Jev is not used as a free-form text generator. A generative model can draft a reply while a separate Jev-backed procedure evaluates it, each with its own lexical model configuration.
| Primitive | What it expresses |
|---|---|
BooleanCriteria |
Positive and negative evidence for a decision |
ChoiceCriteria |
The meaning of each Literal or enum option |
Probability |
A finite float constrained to [0, 1] |
Rubric |
Ordered criteria mapped to bounded numeric scores |
Beyond true or false: score against an explicit rubric
> import: decisions
> model: typesafe/jev-latest
~Assessment(
grounded: Annotated[Probability, "Is the reply supported by the policy?"],
helpfulness: Annotated[
float,
"How useful is the next step offered to the customer?",
`Rubric(["No next step", "Vague suggestion", "Specific, actionable next step"])`
]
)
>> The policy requires an order number before a delayed parcel can be investigated.
The reply says: "Please send your order number so we can investigate the delay."
The assessment of this reply against the policy is [assessment: Assessment].
= `assessment`
grounded is between 0 and 1; this three-level rubric produces a score between
0 and 2. Neither value is a proof of correctness or guaranteed calibration.
Install with uv sync --dev --extra typesafe and set TYPESAFE_API_KEY.
The source development environment includes the shared decision types.
Both Pydantic AI and LangChain integrations are supported.
decision_info(...) and kedi.capture_decisions() expose recorded evidence,
including applicable probabilities and thresholds, without another inference.
The shared primitives also support local Laya models through
kedi-decisions.
Jev setup · Decision types · Inspecting evidence
Python Goes Both Ways
Import Python libraries inside Kedi, or expose a Kedi template as a typed Python function. You do not need to move your application into a new language all at once.
import kedi
@kedi.query
def draft_notice(update: str) -> str:
"""kedi
>> Summarize the confirmed facts in <update> without inventing a recovery time.
The customer-facing notice is [notice: str].
= `notice`
"""
...
notice = draft_notice("Checkout is timing out; recovery has not been confirmed.")
@kedi.bind connects a .kedi file to a Python function; @kedi.type exposes
Python types. kedi.context(...) provides scoped configuration overrides.
Complete Python workflow · Python API
Keep Heavy Work Remote
Keep orchestration local and delegate execution to an A2A agent in a sandbox. Authentication belongs to the connection, with credentials kept outside source.
Kedi · connect to your own deployed agent
> agent: a2a:
endpoint: https://agents.example.com
auth:
scheme: bearer
token_env: RESEARCH_AGENT_TOKEN
[summary] << Inspect the repository and summarize its release blockers.
= <summary>
The serving agent owns its model, tools, and execution environment. Kedi can
also serve an exported profile with kedi a2a serve. Kedi peers negotiate
typed-output support; generic peers can return a task summary. This example
needs a real endpoint, its credentials, and the a2a extra.
Built Around the Whole Program
| Surface | What you can do |
|---|---|
| Tools and MCP | Expose typed procedures, Python functions, or MCP tools to a scoped agent |
| Artifacts | Keep large tool results outside model history; read, search, or process the relevant parts |
| Approvals and budgets | Control tool execution and bound model requests, tool attempts, and subagent work |
| Test, eval, optimize | Keep tests, datasets, scoring, and prompt optimization beside the procedure |
| Notebook and REPL | Explore a program incrementally with kedi notebook or kedi --idle |
| Editor tooling | Use VS Code or Zed with completion, diagnostics, hovers, and a debugger |
One language, multiple execution surfaces. Pydantic AI and LangChain sit at the framework integration boundary. Codex, Claude, ACP, and A2A provide agent-harness integrations. Profiles declare required capabilities, and Kedi rejects unsupported combinations rather than silently changing their meaning. Optional surfaces require their respective dependencies and credentials.
Programs to Explore
Each example has a guide, inputs, and a runnable entrypoint.
| Start here | Then explore |
|---|---|
| Meeting actions: nested typed extraction | Support reply: a policy-reading tool and scoped agent |
| Module imports: no-model, deterministic code | Parallel review: typed subagent results |
| Jev routing: criteria-driven decisions | Flappy Kedi: a decision-model-controlled pixel game |
| Release notes: conditions and loops | Knapsack: executable scoring and prompt optimization |
A decision loop you can watch: Flappy Kedi
The pilot is a Kedi program; Python and Pygame handle physics and rendering. Try the decision loop with Jev or local Laya, or take over with manual controls. Source and guide.
All examples · What was actually tested · Terminal-Bench results and methodology
Develop With Kedi
kedi main.kedi --parse # Parse without executing
kedi main.kedi --test # Run colocated tests
kedi main.kedi --eval # Evaluate dataset-backed metrics
kedi --idle # Interactive terminal session
kedi notebook # Local notebook; requires the notebook extra
Use > show: to display values; = returns. The
language specification describes the semantics in detail.
See CONTRIBUTING.md for development setup and quality gates,
or join the conversation to share a program or
discuss the language. Kedi is licensed under Apache 2.0.
Kedi snippets use Python coloring in this README because GitHub's built-in syntax highlighting does not yet include Kedi. They are Kedi source, not Python. The documentation and editor extensions use Kedi's own grammar.
Metadata
Release files for kedi 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kedi-0.1.5.tar.gz | 812.0 kB | Without provenance | Details for kedi-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kedi-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for kedi-0.1.5-py3-none-any.whl |
Total release size: 1.8 MB
Release files / kedi-0.1.5.tar.gz
| Download URL | kedi-0.1.5.tar.gz |
|---|---|
| Size | 812.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33ad2b860802f9e859452a82d299d67222df74d1d7ddf217c9502ffbe0557b39
|
|
BLAKE2b-256 checksum How to use checksums |
2e8ba0d33712bf6cab9f33970966afd27ab7c37ebc1a06611bab85d954fd8253
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / kedi-0.1.5-py3-none-any.whl
| Download URL | kedi-0.1.5-py3-none-any.whl |
|---|---|
| Size | 1.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
299079c92f10b82a4a6b0219b9ece1ea8cbcc459562d8197762bc260aaafe18c
|
|
BLAKE2b-256 checksum How to use checksums |
861adefd19157519f34be49c4358efbfaf9e98457dba82f378c9c7775a70381c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for kedi 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.