🚀 Quick Start - 💻 CLI Usage - 📚 SDK Usage - 🔧 Development
Requires Python 3.11+
Install:
pip install r9sOr directly execute the CLI:
uvx r9sSet your API key via .env file (recommended) or environment variable:
# Option 1: Create .env in your project directory
cat > .env << 'EOF'
R9S_API_KEY=your_api_key
R9S_BASE_URL=https://api.r9s.ai/v1
R9S_MODEL=gpt-5-mini
EOF
# Option 2: Export environment variables
export R9S_API_KEY="your_api_key"The CLI automatically loads .env from the current directory (SDK usage does not auto-load). Disable with R9S_NO_DOTENV=1.
Chat (interactive, streaming by default):
r9s chatChat (stdin, useful for scripts/pipes):
echo "hello" | r9s chat
cat image.png | r9s chatResume a saved chat session (interactive selection):
r9s chat --resumeAgents (versioned, with audit trails, stored under ~/.r9s/agents/<name>/):
# Create an agent
r9s agent create reviewer \
--instructions "You are a code reviewer. Focus on bugs and security." \
--model gpt-5-mini
# Chat with the agent
r9s chat --agent reviewer
# Agents support variables
r9s agent create code-reviewer \
--instructions "Review {{language}} code for {{focus_areas}}" \
--model gpt-5-mini
r9s chat --agent code-reviewer --var language=Python --var focus_areas="security, performance"
# Pull an agent definition from git
r9s agent pull github:my-org/agent-definitions --path agents/reviewerCommands (saved as TOML under ~/.r9s/commands/<name>.toml, prompt template only):
r9s command create summarize --prompt "Summarize: {{args}}"In interactive chat, commands are available as slash commands:
/summarize hello world
Command templates:
{{args}}is replaced by the slash command arguments.!{...}runs a local shell command (bash -lc ...) after confirmation; pass-yto skip confirmation.
Run apps with r9s env injected (supported: claude-code, cc):
r9s run cc --model "$R9S_MODEL"Configure local tools (supported: claude-code, cc, codex, qwen-code):
r9s set claude-code
r9s reset claude-codeEnable bash completion:
eval "$(r9s completion bash)"Web UI (Streamlit):
pip install "r9s[web]"
r9s web --open-browserMore details: docs/web-ui.md
List available models:
r9s models
r9s models --details # Show owner and creation dateAudio (TTS, transcription, translation):
# Text to speech
r9s audio speech "Hello world" -o hello.mp3
r9s audio speech "Welcome" -o welcome.wav -v nova
# Speech to text (transcription)
r9s audio transcribe recording.mp3
r9s audio transcribe meeting.wav -o transcript.txt -f text
# Translate audio to English
r9s audio translate chinese_audio.mp3 -o english.txtSee all options:
r9s -h
r9s chat -h
r9s agent -h
r9s command -h
r9s audio -h
r9s models -h
r9s run -hMinimal example (reads R9S_API_KEY and optional R9S_BASE_URL from the environment):
from r9s.client import R9S
with R9S.from_env() as r9s:
res = r9s.chat.create(model="gpt-4o-mini", messages=[
{
"role": "user",
"content": "Hello, how are you?",
},
], stream=False)Advanced SDK usage: docs/sdk-advanced.md
Clone and install in editable mode with dev dependencies:
git clone https://github.com/r9s-ai/r9s-python.git
cd r9s-python
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev,test]"Run tests:
pytestRun linting/type checks:
ruff check src/
pyright
mypy src/