Skip to content

chantraio/cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chantra CLI

What it is

chantra is a standalone Linux/POSIX command-line client for the Chantra public API at https://api.chantra.io. It is only a client: it does not run a server, use backend packages, store channels, or persist keys.

Installation

Download or build the single chantra binary and place it on your PATH.

Build from source

make build
# or
go build -o bin/chantra ./cmd/chantra

Create a channel

chantra channel create --visibility public --output env
chantra channel create --visibility private --output env

Grant read access for private channels

chantra channel grant-read \
  --publish-key "$CHANTRA_PUBLISH_KEY" \
  "$CHANTRA_CHANNEL_URL" \
  --output env

Publish messages

echo "hello" | chantra publish --publish-key "$CHANTRA_PUBLISH_KEY" "$CHANTRA_CHANNEL_URL"
go run main1.go | chantra publish --publish-key "$CHANTRA_PUBLISH_KEY" "$CHANTRA_CHANNEL_URL"

Read messages

chantra read --read-key "$CHANTRA_READ_KEY" "$CHANTRA_CHANNEL_URL"
chantra read --read-key "$CHANTRA_READ_KEY" "$CHANTRA_CHANNEL_URL" | go run main2.go

Use in Unix pipelines

chantra read \
  --read-key "$INPUT_READ_KEY" \
  "$INPUT_CHANNEL_URL" \
| go run processor.go \
| chantra publish \
  --publish-key "$OUTPUT_PUBLISH_KEY" \
  "$OUTPUT_CHANNEL_URL"

Message formats

publish --format lines sends each line as one message; raw sends all stdin as one message; jsonl validates each input line as JSON. read --format lines emits payloads, raw emits payload bytes, jsonl emits JSON Lines metadata, and sse passes through SSE frames.

Environment variables

Optional: CHANTRA_API_BASE_URL, CHANTRA_PUBLISH_KEY, CHANTRA_READ_KEY. Flags override environment variables.

export CHANTRA_PUBLISH_KEY="..."
echo "hello" | chantra publish "$CHANTRA_CHANNEL_URL"

export CHANTRA_READ_KEY="..."
chantra read "$CHANTRA_CHANNEL_URL"

Security notes

Keys are sent in headers, never stored locally, and must not be logged. Normal pipeline data is written to stdout; diagnostics and errors go to stderr.

Development

make fmt
make vet
make build

Testing

make test

REST endpoint constants in internal/api/endpoints.go are based on https://chantra.io/llms.txt: POST /channels, POST /channels/{channelID}/publish, and POST /channels/{channelID}/read-grants under https://api.chantra.io/v1.

About

CLI tool for Chantra.io that supports POSIX pipes

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors