chr15m/runprompt: Tiny script to run .prompt files

A single-file Python script to run .prompt files.

Quick Start | Example configuration | providers

curl -O https://raw.githubusercontent.com/chr15m/runprompt/main/runprompt
chmod +x runprompt

create hello.prompt,

---
model: anthropic/claude-sonnet-4-20250514
---
Say hello to {{name}}!

run it:

export ANTHROPIC_API_KEY="your-key"
echo '{"name": "World"}' | ./runprompt hello.prompt

In addition to the following, see the test folder for more examples .prompt files.

---
model: anthropic/claude-sonnet-4-20250514
---
Summarize this text: {{STDIN}}
cat article.txt | ./runprompt summarize.prompt

Specific {{STDIN}} The variable always contains raw stdin as a string.

Extract structured data using output schema:

---
model: anthropic/claude-sonnet-4-20250514
input:
  schema:
    text: string
output:
  format: json
  schema:
    name?: string, the person's name
    age?: number, the person's age
    occupation?: string, the person's job
---
Extract info from: {{text}}
echo "John is a 30 year old teacher" | ./runprompt extract.prompt
# {"name": "John", "age": 30, "occupation": "teacher"}

fields ending with ? are optional. the format is field: type, description,

Pipe structured output between signals:

echo "John is 30" | ./runprompt extract.prompt | ./runprompt generate-bio.prompt

The JSON output from the first prompt becomes a template variable in the second.

Override any Frontmatter value from the command line:

./runprompt --model anthropic/claude-haiku-4-20250514 hello.prompt
./runprompt --name "Alice" hello.prompt

Set up API keys for your providers:

export ANTHROPIC_API_KEY="..."
export OPENAI_API_KEY="..."
export GOOGLE_API_KEY="..."
export OPENROUTER_API_KEY="..."

Override any Frontmatter value via prefixed environment variable RUNPROMPT_,

export RUNPROMPT_MODEL="anthropic/claude-haiku-4-20250514"
./runprompt hello.prompt

This is useful for setting defaults across multiple prompt runs.

Use -v To view request/response details:

./runprompt -v hello.prompt

Models are specified as provider/model-name,

providermodel formatapi key env var
anthropicanthropic/claude-sonnet-4-20250514ANTHROPIC_API_KEY
OpenAIopenai/gpt-4oOPENAI_API_KEY
google aigoogleai/gemini-1.5-proGOOGLE_API_KEY
openrouteropenrouter/anthropic/claude-sonnet-4-20250514OPENROUTER_API_KEY

OpenRouter provides access to models from multiple providers (Anthropic, Google, Meta, etc.) through a single API key.



<a href

Leave a Comment