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, and the model side is pluggable: a program runs on Pydantic AI or LangChain, or through Codex, Claude, ACP, and A2A agents.
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.")`$ kedi main.kedi
[Action(task='add tests', owner='Sam', deadline='Friday')]~Action declares a type and @extract_actions a procedure. >> starts a
template, the text sent to the model, and <notes> inserts a value into it.
[actions: list[Action]] declares a capture: the model sees it inside the
sentence that gives it meaning, alongside the output schema, and actions
then holds a validated list of Action objects, not text to parse later.
Backticks hold Python expressions, and = returns a value from the procedure
or the program. The redesign was only a suggestion, so it is not in the list.
| 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
pip install kedi
export OPENAI_API_KEY="..."
kedi --idlekedi --idle opens 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. The default
model is OpenAI's gpt-6-luna; the
installation guide
covers other providers and optional extras.
$ kedi --idle
+++ [country] = Sweden
+++ >> The capital of <country> is [capital: str].
+++ :show <capital>
Stockholm
+++ :show `capital.upper()`
STOCKHOLMKedi 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.
Run the Examples
Clone the repository to run its examples 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
kedi examples/meeting_actions/main.kediSet OPENAI_API_KEY in your environment or the checkout's .env; 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 PyPI badge reports the published release, which may lag the source examples.
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."])`Independent template calls run concurrently by default, with no special
syntax: dependent calls wait for their inputs, and calls sharing a conversation
keep their turn order. Use a Python condition such as > if: `count > 0`:
for a deterministic branch, and attach > map: to a loop to process each
iteration's outputs as they resolve.
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
Images, Audio, and Documents Are Values
image, audio, video, and document load a local file, an http(s) URL,
or a data: URI. A prompt passes a value by reference with <<name>>: the text
gets the name and the value is attached to the model's context. <name> always
renders text, so <photo> is a type error for an image.
Kedi · read a receipt photo into a typed value
> import: media
~Receipt(merchant: str, total: float, currency: str)
@read_receipt(photo: Image) -> Receipt:
>> Read the receipt in <<photo>>.
The receipt details are [receipt: Receipt].
= `receipt`
= `read_receipt(image("receipt.png"))`The model receives the image inside <image id="photo" type="image/png">, under
the name the program uses rather than receipt.png, and the sentence reads
"Read the receipt in photo." Text, lists and models referenced the same way
arrive as <document> elements. URL attachments retain their source URLs.
Media works with the Pydantic AI and LangChain adapters on OpenAI, Anthropic,
Google Gemini, and AWS Bedrock. Kedi rejects an attachment the provider cannot
take before calling the model.
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:
decision_boolean_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 |
> 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 pip install "kedi[typesafe]", which includes the shared decision
types, and set TYPESAFE_API_KEY; the source development environment has both.
Jev works with the Pydantic AI and LangChain adapters.
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 |
| OpenTelemetry | Trace program runs, model and tool calls, subagents, and artifacts; content capture is off by default |
| MCP server | Let an MCP client parse, run, test, and evaluate Kedi programs through kedi-mcp
|
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.
Measured on real engineering tasks. In two single-trial Terminal-Bench 2.1
runs, Kedi's agent harness with codex/gpt-5.6-luna solved 68 of 89 tasks on
both the Pydantic AI and the LangChain adapter, at about six cents of
API-equivalent model cost per task. These are engineering runs, not leaderboard
submissions; see the results and methodology.
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 |
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
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 extraUse > 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.

