Skip to main content

onechat

CI PyPI version Python 3.12+ License: MIT

The Problem: You are deep into a coding or debugging session with Claude Code, Codex, or Gemini CLI—then you hit a rate limit, quota wall, or timeout. Switching tools means starting a fresh terminal and re-explaining your entire context from scratch.

The Solution: onechat gives you one persistent chat session that survives AI backend switches. It automatically detects quota/auth/timeout failures, places the failing backend on cooldown, generates a compact handoff brief (plus current git state), and continues the exact same conversation on the next available CLI agent or OpenAI-compatible API.


Supported Backends

Backend Kind Profile / Parser Notes
Claude Code (claude) CLI claude Native JSONL stream + session resume
OpenAI Codex (codex) CLI codex Native JSONL stream + session resume
Google Gemini CLI (gemini) CLI gemini Stream JSON + session resume
OpenCode (opencode) CLI opencode Multi-provider CLI + model routing
Qwen Code (qwen) CLI qwen Stream JSON + session resume
OpenAI-compatible APIs API kind: api Groq, OpenRouter, DeepSeek, Cerebras, local vLLM/Ollama
Additional CLI profiles CLI agy, autoclaw, workbuddy, qoder, zcode Built-in YAML profiles + custom ~/.onechat/profiles/*.yaml

How It Works

flowchart LR
    U["User / SDK / CLI (`onechat chat` or `onechat run`)"] --> R["Router"]
    R --> S["Selector (Tier, Capabilities, Skills, Cost)"]
    S --> Q["Quota & Cooldown Book (SQLite WAL)"]
    Q -->|Available| E1["Primary Executor (CLI / API)"]
    E1 -->|Quota / Timeout / Error| H["Handoff Brief + Git State"]
    H --> E2["Fallback Executor (Next Backend)"]
    E1 -->|Done| DB[("~/.onechat/onechat.db")]
    E2 -->|Done| DB
  • Same backend next turn? Uses native session resume (--resume) for zero extra token overhead.
  • Switched to a different backend? Injects a bounded <asf-handoff> summary + recent turns + current git status/diff so the new model picks up seamlessly.
  • Zero secrets stored: API keys are read strictly from environment variables (os.environ or ~/.onechat/env) and automatically redacted from logs, errors, and SQLite.

Installation

Package on PyPI: https://pypi.org/project/onechat-cli/
Source on GitHub: https://github.com/abolfazl-moeini/onechat

# Install globally as a CLI tool (recommended)
uv tool install onechat-cli

# Or with pip
pip install onechat-cli

# Or run one-off without installing
uvx --from onechat-cli onechat doctor

Quick Start

# 1. Check installed CLI binaries, API key env vars, and SQLite DB
onechat doctor

# 2. Start an interactive multi-backend chat REPL
onechat chat

# 3. Run a single turn in a persistent session
onechat run "Find why tests/test_auth.py is flaky" --session my-debug

# 4. Inspect executor pool, cooldowns, and session history
onechat executors list
onechat sessions list
onechat sessions export my-debug --format md

Inside onechat chat:

  • /use <executor> — switch backend mid-conversation without losing context
  • /tier low|medium|high — override reasoning/cost tier
  • /status — inspect active session, executor, and cooldowns
  • /exit — quit

Configuration (~/.onechat/config.yaml)

onechat works out of the box with defaults, and deep-merges ~/.onechat/config.yaml (or $ONECHAT_CONFIG).

db_path: ~/.onechat/onechat.db

# Optional: define your prioritized executor pool (free -> subscription -> paid)
executors:
  - id: codex-main
    kind: cli
    profile: codex
    tier: 3
    cost: subscription
    capabilities: [chat, code]

  - id: claude-main
    kind: cli
    profile: claude
    tier: 3
    cost: subscription
    capabilities: [chat, code]

  - id: gemini-cli
    kind: cli
    profile: gemini
    tier: 2
    cost: free
    capabilities: [chat, code]

  - id: groq-fast
    kind: api
    base_url: https://api.groq.com/openai/v1
    model: llama-3.3-70b-versatile
    api_key_env: GROQ_API_KEY
    tier: 2
    cost: free
    capabilities: [chat]

  - id: openrouter-fallback
    kind: api
    base_url: https://openrouter.ai/api/v1
    model: qwen/qwen3-coder:free
    api_key_env: OPENROUTER_API_KEY
    tier: 3
    cost: free
    capabilities: [chat, code]

tier_policy:
  cost_order: [free, subscription, paid]
  allow_paid: false

cooldown:
  quota_cooldown_s: 7200
  timeout_cooldown_s: 7200
  error_cooldown_s: 14400
  auth_cooldown_s: 86400
  share_profile_cooldown: true

handoff:
  recent_turns: 6
  turn_max_chars: 4000
  brief_max_chars: 24000
  compact_threshold_chars: 30000

roles:
  builder: codex
  reviewer: claude
  auditor: codex

Python SDK

from onechat import OneChatClient

client = OneChatClient()
session = client.session(workdir=".")

# Turn 1: runs on the best available executor
reply1 = session.ask_sync("Summarize the architecture of src/")
print(f"[{reply1.executor_id}] {reply1.text}")

# Turn 2: force a switch or let failover handle quota automatically
reply2 = session.ask_sync("Now write unit tests for the config loader", executor="claude-main")
print(f"[{reply2.executor_id}] {reply2.text}")

Metadata

Release files for onechat-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onechat-cli 0.2.0
File Size Uploaded Provenance Actions
onechat_cli-0.2.0.tar.gz 52.6 kB Without provenance Details for onechat_cli-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for onechat-cli 0.2.0
File Interpreter ABI Platform Actions
onechat_cli-0.2.0-py3-none-any.whl Python 3 none any Details for onechat_cli-0.2.0-py3-none-any.whl

Total release size: 121.9 kB

Release files / onechat_cli-0.2.0.tar.gz

Download URL onechat_cli-0.2.0.tar.gz
Size 52.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a29fe5b311e7b2909f93eb0334068be22a2b27784e13195fa21b302b627cfe25
BLAKE2b-256 checksum
How to use checksums
3f871720f32a9fa1ef2f248b3519ee2cce6b61a99d01e5ee989acb2d9a394ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / onechat_cli-0.2.0-py3-none-any.whl

Download URL onechat_cli-0.2.0-py3-none-any.whl
Size 69.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
206860b340b16911902ec06293694c713d41f542708825731edb0484c1f26989
BLAKE2b-256 checksum
How to use checksums
b56994af56a040e18052e78402474234c890b3f336b2a6a2e287d81e10039f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for onechat-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page