Metadata-Version: 2.4
Name: tx-ai
Version: 0.1.1
Summary: Modern Textual chat client for OpenRouter with sessions, MCP search, and model selection
License-Expression: MIT
License-File: LICENSE
Keywords: ai,chat,openrouter,terminal,textual
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: httpx<1.0,>=0.28.0
Requires-Dist: loguru<1.0,>=0.7.3
Requires-Dist: openai<2.0,>=1.76.0
Requires-Dist: textual<1.0,>=0.61.0
Description-Content-Type: text/markdown

# tx-ai

Modern terminal chat UI built with Textual, `uv`, OpenRouter, and the OpenAI Python client.

## Requirements

- Python 3.11+
- OpenRouter API key via `OPENROUTER_API_KEY`, saved local config, or the startup prompt

## Install

From this checkout:

```bash
python -m pip install .
```

Or with `uv`:

```bash
uv sync
```

## Run With An Env Key

```bash
uv run --env-file .env tx-ai
```

If installed with `pip`:

```bash
OPENROUTER_API_KEY=your_key_here tx-ai
```

## Run Without An Env Key

```bash
tx-ai
```

If `OPENROUTER_API_KEY` is not set, the app asks for your OpenRouter API key in the input box. The key is saved to your local user config at `~/.config/tx-ai/config.json` with file mode `0600`, so tx-ai will not ask again after reopening. If OpenRouter rejects the key as expired or invalid, tx-ai clears the saved key and asks for a new one.

## UI Features

- Chat interface with Markdown rendering.
- Loading spinner while OpenRouter is generating.
- Model selector in the terminal UI.
- Slash commands for common chat actions.
- English replies by default unless you explicitly ask for another language.
- Parallel Search MCP-backed web search.
- Cleaner internal structure split across config, commands, OpenRouter API, and UI modules.

## Slash Commands

- `/help` shows available commands.
- `/new` starts a fresh in-memory conversation.
- `/sessions` shows saved sessions so you can select one and continue it.
- `/mcps` shows configured MCP servers, connection status, and exposed tools.
- `/models` lists preset models.
- `/model <model>` switches model by exact name or unique substring.
- `/search <query>` searches the web with Parallel Search MCP and adds results to chat context.
- `/copy` or `/copy last` copies the last assistant reply.
- `/copy all` copies the full current session transcript.
- `/copy user` copies your last message.
- `/clear` clears the visible chat log.
- `/exit` quits the app.

Keyboard shortcuts:

- `Ctrl+Y` copies the last assistant reply.
- `Ctrl+L` clears the visible chat log.
- `Ctrl+Q` quits the app.

## Web Search

tx-ai includes `/search`, backed by the Parallel Search MCP endpoint documented at <https://docs.parallel.ai/integrations/mcp/search-mcp>.

Normal messages that ask to search the web, use the internet/MCP, or answer current/latest/today/live questions automatically run Parallel Search MCP before the model replies. If the model first replies that it does not know, cannot browse, or lacks current information, tx-ai automatically runs a fallback Parallel Search MCP lookup and regenerates the answer.

```text
/search latest OpenRouter model updates
```

The project also includes `opencode.json` so OpenCode can use the same MCP server by default:

```json
{
  "mcp": {
    "parallel-search": {
      "type": "remote",
      "url": "https://search.parallel.ai/mcp",
      "enabled": true
    }
  }
}
```

Use `/mcps` inside tx-ai to verify which MCP servers are configured and connected.

## Sessions

tx-ai saves conversations locally under `~/.config/tx-ai/sessions/`. Session titles are created from the first user message.

Use this command in the app:

```text
/sessions
```

Select a saved session from the list to reopen it. The chat history and model are restored so you can continue the conversation.

## Model Selection

Use the model selector in the top bar, or run:

```text
/model deepseek
```

To set a custom default model before launch:

```bash
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet tx-ai
```

## Build A Wheel

```bash
uv build
python -m pip install dist/tx_ai-0.1.0-py3-none-any.whl
```

## Publish

```bash
uv build
uv publish --token YOUR_PYPI_TOKEN
```

## Notes

- Default model is `deepseek/deepseek-v4-flash` unless `OPENROUTER_MODEL` is set.
- Replies default to English through a system instruction.
- Conversations are saved locally and can be reopened with `/sessions`.
- If no API key is set or saved, the app prompts for one at startup.
- Assistant replies and model thinking are rendered as Markdown.
- Runtime logs are written to `logs/tx-ai.log`.
