Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,25 @@ sudo mv ./tmuxai /usr/local/bin/

After installing TmuxAI, you need to configure your API key to start using it:

1. **Set the API Key**
TmuxAI uses the OpenRouter endpoint by default. Set your API key by adding the following to your shell configuration (e.g., `~/.bashrc`, `~/.zshrc`):
1. **Set the API Key**
TmuxAI supports multiple AI providers. Choose one of the following:

**OpenAI:**
```bash
export TMUXAI_OPENROUTER_API_KEY="your-api-key-here"
export TMUXAI_OPENAI_API_KEY="your-openai-api-key-here"
export TMUXAI_OPENAI_MODEL="gpt-5-codex"
```

**OpenRouter (Default):**
```bash
export TMUXAI_OPENROUTER_API_KEY="your-openrouter-api-key-here"
```

**Azure OpenAI:**
```bash
export TMUXAI_AZURE_OPENAI_API_KEY="your-azure-api-key-here"
export TMUXAI_AZURE_OPENAI_API_BASE="https://your-resource.openai.azure.com/"
export TMUXAI_AZURE_OPENAI_DEPLOYMENT_NAME="your-deployment"
```

2. **Start TmuxAI**
Expand All @@ -121,6 +135,8 @@ After installing TmuxAI, you need to configure your API key to start using it:
tmuxai
```

**Provider Priority:** If multiple API keys are configured, TmuxAI will use them in this order: OpenAI → Azure OpenAI → OpenRouter.

## TmuxAI Layout

![Panes](https://tmuxai.dev/shots/panes.png?lastmode=1)
Expand Down Expand Up @@ -331,8 +347,18 @@ All configuration options can also be set via environment variables, which take
# Examples
export TMUXAI_DEBUG=true
export TMUXAI_MAX_CAPTURE_LINES=300
export TMUXAI_OPENROUTER_API_KEY="your-api-key-here"

# OpenAI (Responses API)
export TMUXAI_OPENAI_API_KEY="your-openai-api-key-here"
export TMUXAI_OPENAI_MODEL="gpt-5-codex"
export TMUXAI_OPENAI_BASE_URL="https://api.openai.com/v1" # Optional

# OpenRouter (Chat Completions API)
export TMUXAI_OPENROUTER_API_KEY="your-openrouter-api-key-here"
export TMUXAI_OPENROUTER_MODEL="..."
export TMUXAI_OPENROUTER_BASE_URL="https://openrouter.ai/api/v1" # Optional

# Azure OpenAI (Chat Completions API)
export TMUXAI_AZURE_OPENAI_API_KEY="your-azure-api-key"
export TMUXAI_AZURE_OPENAI_API_BASE="https://your-resource.openai.azure.com/"
export TMUXAI_AZURE_OPENAI_API_VERSION="2025-04-01-preview"
Expand All @@ -343,8 +369,12 @@ You can also use environment variables directly within your configuration file v

```yaml
# Example config.yaml with environment variable expansion
openrouter:
openai:
api_key: "${OPENAI_API_KEY}"
model: "gpt-5"

openrouter:
api_key: "${OPENROUTER_API_KEY}"
base_url: https://api.openai.com/v1
```

Expand All @@ -358,16 +388,32 @@ TmuxAI » /config

# Override a configuration value for this session
TmuxAI » /config set max_capture_lines 300
TmuxAI » /config set openai.model gpt-5-codex
TmuxAI » /config set openai.api_key "your-api-key"
TmuxAI » /config set openai.base_url "https://api.openai.com/v1"
TmuxAI » /config set openrouter.model gpt-4o-mini
```

These changes will persist only for the current session and won't modify your config file.

### Using Other AI Providers

OpenRouter is OpenAI API-compatible, so you can direct TmuxAI at OpenAI or any other OpenAI API-compatible endpoint by customizing the `base_url`.
TmuxAI supports multiple AI providers with different API formats:

#### OpenAI (Responses API)

For the best experience with new OpenAI models like GPT-5, use the dedicated OpenAI configuration:

```yaml
openai:
api_key: "your-openai-api-key"
model: "gpt-5-codex"
base_url: "https://api.openai.com/v1" # Optional, defaults to this
```

#### OpenRouter (Chat Completions API)

For OpenAI:
OpenRouter is OpenAI API-compatible, so you can direct TmuxAI at OpenAI or any other OpenAI API-compatible endpoint by customizing the `base_url`:

```yaml
openrouter:
Expand Down Expand Up @@ -403,7 +449,9 @@ openrouter:
base_url: http://localhost:11434/v1
```

For Azure OpenAI:
#### Azure OpenAI (Chat Completions API)

For Azure OpenAI deployments:

```yaml
azure_openai:
Expand All @@ -413,6 +461,16 @@ azure_openai:
deployment_name: "gpt-4o"
```

#### Provider Selection

TmuxAI automatically selects the AI provider based on configuration priority:

1. **OpenAI** (Responses API) - If `openai.api_key` is configured
2. **Azure OpenAI** (Chat Completions) - If `azure_openai.api_key` is configured
3. **OpenRouter** (Chat Completions) - Default fallback

You can override the provider at runtime by setting the appropriate API key and model configuration.

_Prompts are currently tuned for Gemini 2.5 by default; behavior with other models may vary._

## Contributing
Expand Down
16 changes: 8 additions & 8 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ send_keys_confirm: true # Confirm before executing send keys
paste_multiline_confirm: true # Confirm before pasting multiline content
exec_confirm: true # Confirm before executing commands

# Not only OpenRouter, you can use any OpenAI compatible API
# OpenAI Responses API (recommended for new models like GPT-5)
# openai:
# api_key: sk-XXXXXXXXX
# model: gpt-5-codex
# base_url: https://api.openai.com/v1 # Optional, defaults to this

# With openRouter, you can use any chat completion api
openrouter:
api_key: sk-or-v1-XXXXXXXXX
model: google/gemini-2.5-flash-preview # default model
Expand All @@ -19,16 +25,10 @@ openrouter:
# api_version: 2025-04-01-preview
# deployment_name: gpt-4o

# OpenAI example
# openrouter:
# api_key: sk-XXXXXXXXX
# model: o4-mini-2025-04-16
# base_url: https://api.openai.com/v1

# Anthropic example
# openrouter:
# api_key: sk-proj-XXX
# model:
# model: claude-4.5-sonnet
# base_url: https://api.anthropic.com/v1

# Local Ollama example
Expand Down
11 changes: 11 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
WhitelistPatterns []string `mapstructure:"whitelist_patterns"`
BlacklistPatterns []string `mapstructure:"blacklist_patterns"`
OpenRouter OpenRouterConfig `mapstructure:"openrouter"`
OpenAI OpenAIConfig `mapstructure:"openai"`
AzureOpenAI AzureOpenAIConfig `mapstructure:"azure_openai"`
Prompts PromptsConfig `mapstructure:"prompts"`
}
Expand All @@ -33,6 +34,13 @@ type OpenRouterConfig struct {
BaseURL string `mapstructure:"base_url"`
}

// OpenAIConfig holds OpenAI API configuration
type OpenAIConfig struct {
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"`
BaseURL string `mapstructure:"base_url"`
}

// AzureOpenAIConfig holds Azure OpenAI API configuration
type AzureOpenAIConfig struct {
APIKey string `mapstructure:"api_key"`
Expand Down Expand Up @@ -65,6 +73,9 @@ func DefaultConfig() *Config {
BaseURL: "https://openrouter.ai/api/v1",
Model: "google/gemini-2.5-flash-preview",
},
OpenAI: OpenAIConfig{
BaseURL: "https://api.openai.com/v1",
},
AzureOpenAI: AzureOpenAIConfig{},
Prompts: PromptsConfig{
BaseSystem: ``,
Expand Down
Loading