SparkLang — the Spark programming language

A language and runtime for readable AI workflows

Write programs in plain .spark files. Dry-run offline with fixtures, or run live ask against your own OpenAI-compatible gateway. Download the runtime, try the playground, or start with the learn guides.

What you can do

Ask + print

Call a model with ask, bind the result, and print it. Dry-run uses offline fixtures.

ask "Explain gravity in one sentence" -> text
print text

Dry-run · optional live

./spark --dry-run uses offline fixtures. Pass --live with your own AI_GATEWAY_URL when you want real model calls.

ask "Summarize: {doc}" -> text
./spark --dry-run my_task.spark

Voice

Optional listen / speak for local demos.

voice {
  listen -> user
  classify Intent { support, sales } from user -> intent
  ask "Reply as {intent}: {user}" -> reply
  speak reply
}

Playbooks

Ready-made .spark snippets for common tasks (fix tests, refactor, review).

include "lib/ai.spark"
ask "Fix this test failure: {msg}" -> fix

embed / retrieve

Language ops with dry fixtures; live via spark-rag-http when you configure a gateway.

embed "SparkLang workflows" -> vec
retrieve "dry-run" from project "docs" -> hits

Train a model

model train / model build submit a real training job (adapters / checkpoints). Dry-run uses fixtures with no GPU and no network. Live uses a pluggable backend (http or allowlisted local-yield).

  1. 1 Train Submit dataset, base, and output path
  2. 2 Status Poll the job and print artifact paths
  3. 3 Ask (optional) Eval the result with live gateway ask if you want
# model_train.spark — dry-run first
model train dataset "examples/fixtures/train/dataset.jsonl" base "fixture-base" out "out/train/job-dry-001" backend "http" -> job
model status "job-dry-001" -> status

Analyze / compare / improve remain eval helpers. model plan writes optional markdown. Model training docs · Build a Model · Language reference.

Voice

Optional listen / speak ops for local demos.

voice {
  listen -> user
  classify Intent { support, sales, billing } from user -> intent
  ask "Reply helpfully to: {user}" -> reply
  speak reply -> "out/turn.wav"
}

# PSTN off by default — placeholders only until you enable gates
voice pstn status -> st
voice pstn dial "+15555550100" -> call

See AI in 5 Minutes — voice, Playground voice tab, and language reference (listen/speak/pstn).

Network & web

Language ops for capture, browser automation, and engine fetch. First-class http get / http post are on the roadmap.

network capture probe -> info
network open "examples/fixtures/sample.pcap" -> pcap
network analyze pcap -> traffic_report

engine fetch "file://examples/fixtures/engine/sample.html"
browser run "examples/browser_main.spark"

Not a Python stub driver — asm dispatch today. First-class http get / http post are [roadmap]; use engine fetch for HTTP now. Network + web guide · Language reference · Browser / MITM

Core vs optional

Language and runtime first. Live gateway, voice, and capture are optional.

Included

Language, dry-run fixtures, playbooks, embed / retrieve, IDE language ops.

Optional

Live ask / embed with --live; voice; browser / capture.

Editor + AI coding

Prefer LSP + syntax highlighting. Verified ide language ops and playbooks remain; homegrown Electron/PyQt chrome is not the product focus.

include "lib/ai.spark"
ide new "out/ide/task.spark"
ide ask "Explain this buffer" -> reply
./spark --dry-run examples/ide_ask_show.spark

Terminal-first IDE today — not Electron product chrome. IDE status · AI models guide · Programming guide

Learn Spark

Follow the tutorial path — same structure as official language docs for Java or C++.

Build a Model

Wizard for analyze → compare → improve → build — modify an Train a model — submit a dry-run job, then poll status, or start from eval helpers and an optional plan file.

Open wizard →

Hello world

# Dry-run — no network, no API key
./spark --dry-run examples/hello.spark

# Optional live ask — any OpenAI-compatible gateway
export AI_GATEWAY_URL=http://127.0.0.1:4000
./spark --live examples/ask_live.spark

Sample program: Then ask "…" -> text. See full programming guide and language reference.