Skip to main content

Agentik — a CLI-first, modular agent framework that runs LLMs via OpenRouter.

Project description

Agentik Framework

Agentik is a CLI‑first, modular agent framework that runs LLMs via OpenRouter. It focuses on developer ergonomics: clean configs, a batteries‑included CLI, safe tool execution, rich transcripts with run metadata, and a dev profile with auto‑rerun watching for fast iteration.


Highlights

  • CLI‑first workflow: agentik run, agentik dev watch, agentik tools ...

  • OpenRouter integration: one key → many models

  • Agent loop: plan → (optional tool) → reflect → finalize

  • Pluggable tooling (via entry points) with built‑ins:

    • http_fetch — GET with caching + limits
    • html_to_text — HTML → text
    • write_file — safe file writer
  • Policies enforced per tool call: allow_network, allow_filesystem

  • Transcripts: JSONL with meta_start/meta_end (tokens, cost estimate, timings, tags)

  • Run profiles: fast, thorough, deterministic, creative, cheap, dev

  • Dev watcher: polling file watcher, auto‑rerun on save (no extra deps)

  • Memory: file‑backed minimal memory (json or in‑memory dict)


Installation

Requires Python 3.10+.

pip install agentik-framework

# for local development
pip install -e .[dev]

OpenRouter API key

Set your key once (recommended):

PowerShell (Windows):

setx OPENROUTER_API_KEY "sk-or-..."
# then restart your shell

Or via Agentik RC:

agentik keys set openrouter sk-or-... --global

Verify your setup:

agentik self-test

End‑User Guide (PyPI + CLI)

Once you’ve installed the package from PyPI, you can use Agentik entirely from the CLI. Here’s a concise, step‑by‑step guide for end users.

1) Install

pip install agentik-framework

Python 3.10+ required.

2) Set your OpenRouter API key (one time)

Windows (PowerShell):

setx OPENROUTER_API_KEY "sk-or-XXXXXXXXXXXXXXXX"
# Open a new PowerShell window afterwards

macOS/Linux (bash/zsh):

echo 'export OPENROUTER_API_KEY="sk-or-XXXXXXXXXXXXXXXX"' >> ~/.bashrc
source ~/.bashrc

Verify:

agentik self-test
agentik models list --filter gpt --refresh   # optional network check

3) Create a project folder

mkdir my-agent && cd my-agent

Initialize a basic layout (templates are bundled with the package):

agentik init . --template basic --name "My Agent Project"

Generate a ready‑to‑run agent config (adds a file under agents/):

agentik new agent research --template basic --tools http_fetch,html_to_text,write_file --with-tests --to .

Want to see available templates and tools?

agentik template list
agentik tools list

4) Minimal config (if you prefer to paste one)

Create configs/agent.yaml with:

agent:
  name: ResearchBot
  goal: "Research and summarize information."
  loop:
    max_steps: 3
    reflect: true

llm:
  model: openai/gpt-4o-mini
  temperature: 0.3

memory:
  type: json
  path: ./memory/research.json

policies:
  allow_network: true
  allow_filesystem: true

tools:
  - http_fetch
  - html_to_text
  - write_file

5) Run your agent

Windows (PowerShell):

agentik run .\agents\agent.yaml `
  -p "Summarize the main differences between GPT-4o and small LLMs in 5 bullets." `
  --profile fast `
  --stream `
  --save-transcript .\runs\first-run.jsonl

macOS/Linux:

agentik run ./agents/agent.yaml \
  -p "Summarize the main differences between GPT-4o and small LLMs in 5 bullets." \
  --profile fast \
  --stream \
  --save-transcript ./runs/first-run.jsonl

Handy flags:

  • --profile fast|thorough|deterministic|creative|cheap|dev|none
  • --model <openrouter-model-id>
  • --temperature <float>
  • --save-transcript <path> — JSONL with metadata, tokens, timings, cost est.
  • --tag, --note, --run-id — stored in transcript metadata

6) Use the dev watcher (auto re‑run on file changes)

PowerShell tip: quote your globs to avoid expansion.

Windows (PowerShell):

agentik dev watch .\agents\agent.yaml `
  --prompt "Summarize this project in 3 bullets." `
  --path . `
  --include '**/*.py' --include '**/*.yaml' --include 'templates/**' `
  --exclude '.venv/**' --exclude 'runs/**' `
  --save-transcripts .\runs `
  --profile dev `
  --stream

macOS/Linux:

agentik dev watch ./agents/agent.yaml \
  --prompt "Summarize this project in 3 bullets." \
  --path . \
  --include '**/*.py' --include '**/*.yaml' --include 'templates/**' \
  --exclude '.venv/**' --exclude 'runs/**' \
  --save-transcripts ./runs \
  --profile dev \
  --stream

7) Run tools directly (no agent loop)

agentik tools run http_fetch --arg url=https://example.com --arg ttl=3600 --arg allow_network=true --json
agentik tools run html_to_text --arg "html=<p>Hello</p>" --arg keep_newlines=true --json
agentik tools run write_file --arg path=out\hello.txt --arg "content=Hello" --arg allow_filesystem=true --json

8) Memory helpers

agentik memory init --type json --path .\memory\agentik.json
agentik memory recall --n 10 --config .\agents\agent.yaml
agentik memory summarize --n 20 --max-chars 1200 --config .\agents\agent.yaml

9) Batch prompts from a file

agentik batch run .\prompts.jsonl --column prompt --out .\results.jsonl --model openai/gpt-4o-mini

prompts.jsonl example:

{"prompt": "Write a haiku about summer."}
{"prompt": "One sentence on the solar eclipse."}

10) Common issues & fixes

“Network error talking to OpenRouter.” Check your key in the same shell: echo $env:OPENROUTER_API_KEY (PowerShell) / echo $OPENROUTER_API_KEY (bash). Try: agentik models list --refresh. If you’re behind a proxy, set HTTP_PROXY/HTTPS_PROXY.

Dev watcher says “unexpected extra arguments …” Quote your globs in PowerShell: --include '**/*.py' (with single quotes).

Not seeing new CLI features after edits? Reinstall in editable mode from your project root: pip install -e .[dev].

That’s it. After pip install agentik-framework you mainly interact through the agentik command. If you want examples or a minimal starter project scaffolded for you, just run agentik init and agentik new agent … and you’ll be up and running in minutes.


Quick Start

Initialize a project:

agentik init . --template basic --name "My Agent Project"

Scaffold an agent:

agentik new agent research \
  --template basic \
  --tools http_fetch,html_to_text,write_file \
  --with-tests

Create a minimal config (save as configs/agent.yaml):

agent:
  name: research
  goal: "Research and summarize web sources"
  loop:
    max_steps: 4
    reflect: true

llm:
  model: openai/gpt-4o-mini
  temperature: 0.2

memory:
  type: json
  path: ./memory/agent.json

policies:
  allow_network: true
  allow_filesystem: true

tools:
  - http_fetch
  - html_to_text
  - write_file

Run it:

agentik run .\agents\agent.yaml -p "Summarize the latest about OpenRouter rate limits"

CLI Reference

agentik version

Print the current version.

agentik self-test

Environment sanity checks (Python, OS, OpenRouter key, RC path).

agentik init

Initialize a project folder.

agentik init [PATH] --template basic --force --name "Project Name"

agentik run

Run an agent loop with profiles and run metadata. (CONFIG is typically a YAML under agents/, e.g., agents/research.yaml.)

agentik run CONFIG \
  -p "Prompt text" \
  --model TEXT \
  --temperature FLOAT \
  --stream \
  --dry-run \
  --save-transcript PATH \
  --profile [fast|thorough|deterministic|creative|cheap|dev|none] \
  --tag TAG \
  --note TEXT \
  --run-id TEXT \
  --obs-max-chars INT

Keys

agentik keys set openrouter sk-or-... [--global|--local]
agentik keys show

Models

agentik models list [--filter TEXT] [--refresh]

New (scaffolding)

agentik new agent NAME \
  --template basic \
  --tools "t1,t2" \
  --memory json \
  --memory-path ./memory/agent.json \
  --to . \
  --with-tests \
  --force

agentik new tool NAME \
  --template python \
  --to . \
  --with-tests \
  --force

Templates

agentik template list
agentik template apply kind/name --to . --force --name MyArtifact
agentik template pull <git-or-zip-url> --to .

Tools

agentik tools list
agentik tools info NAME
agentik tools run NAME --arg key=value --arg key2=value2 [--json]

Validate

agentik validate file CONFIG.yaml \
  --show-effective \
  --model TEXT \
  --temperature FLOAT \
  --max-steps INT

Batch

Process prompts from CSV or JSONL.

agentik batch run FILE \
  --column prompt \
  --out results.jsonl \
  --model TEXT \
  --temperature FLOAT

Memory

agentik memory init --type json --path ./memory/agentik.json
agentik memory recall --n 10 [--config CONFIG.yaml]
agentik memory summarize --n 20 --max-chars 1200 [--config CONFIG.yaml]
agentik memory clear [--config CONFIG.yaml]
agentik memory path [--config CONFIG.yaml]

Eval

Tiny harness to check expected substrings/regex.

agentik eval run FILE.jsonl --config CONFIG.yaml --out eval_results.jsonl

Dev Watch (auto‑rerun)

Watches files and re‑runs on change — great during development.

agentik dev watch CONFIG \
  -p "Prompt text" \
  --prompt-file PATH \
  --path PATH \            # repeatable (default .)
  --include GLOB \         # repeatable (default python/yaml/md/templates/tools)
  --exclude GLOB \         # repeatable
  --interval 0.6 \
  --debounce 0.5 \
  --clear/--no-clear \
  --stream/--no-stream \
  --profile dev \
  --save-transcripts DIR \
  --obs-max-chars 800 \
  --no-initial-run \
  --tag TAG \              # repeatable (default "dev")
  --note TEXT

Example (PowerShell):

agentik dev watch .\agents\agent.yaml `
  --prompt-file .\prompt.txt `
  --path . `
  --include **/*.py --include **/*.yaml --include templates/** `
  --exclude .venv/** --exclude runs/** `
  --save-transcripts .\runs `
  --stream

Tools & Policies

Built‑in tools (selected):

  • http_fetch(url, ttl, timeout, max_bytes, headers, allow_network) Returns {ok, data, error, meta} with data.text, data.status, and cache hints.

  • html_to_text(html, keep_newlines, drop_links, max_chars) Lightweight HTML → text (dependency‑free).

  • write_file(path, content, encoding, overwrite, allow_abs, allow_filesystem) Safe writer with sandboxing and system‑path guards.

Policies (YAML):

policies:
  allow_network: true
  allow_filesystem: false

If a tool requires a disabled capability, Agentik blocks it and records an observation.


Transcripts & Cost

Each run can append JSONL records via --save-transcript. Files include:

  • meta_start: run id, profile, tags, agent, model, policies, memory path
  • Tool calls and assistant responses
  • meta_end: timings (planner/tools/reflect), tokens (prompt/completion/total), estimated cost

Cost is derived from OpenRouter pricing when available. You can override with env vars:

# USD per 1K tokens
$env:AGENTIK_PRICE_PROMPT_PER_1K = "0.50"
$env:AGENTIK_PRICE_COMPLETION_PER_1K = "1.50"

Configuration Reference (YAML)

agent:
  name: my-agent
  goal: "Help with tasks."
  loop:
    max_steps: 4
    reflect: true

llm:
  model: openai/gpt-4o-mini
  temperature: 0.2

memory:
  type: json         # json | dict
  path: ./memory/agent.json

policies:
  allow_network: true
  allow_filesystem: false

tools:
  - http_fetch
  - html_to_text

Development

  • Lint/format: ruff check . and black .
  • Tests: pytest -q
  • Build: python -m build
  • Publish: twine upload dist/*

Authors

License

MIT

Project details


Download files

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

Source Distribution

agentik_framework-0.1.7.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

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

agentik_framework-0.1.7-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

Details for the file agentik_framework-0.1.7.tar.gz.

File metadata

  • Download URL: agentik_framework-0.1.7.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for agentik_framework-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c9fbc556702e4ed8b48fa7416d97e044c664b0d4f0b0830de4a6d1368ef4fdb5
MD5 180a699ef58f2524c93892a0029559d0
BLAKE2b-256 dfa31dbf32d6ed0db67775e19c17ad48a0c442ddc69a79f9163dd1be9fc25c19

See more details on using hashes here.

File details

Details for the file agentik_framework-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for agentik_framework-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1ea9800d7c3889908336ebb04b47ba00530951a5f95373d6032b33f8271b711c
MD5 828a6df6ffbfa9a8dc2a668e98fff86f
BLAKE2b-256 974633f7d01430dc85e7cc84300c6204757fa02188b4a6aa81bfb4dafbe2584d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page