yaroslavyaroslav/OpenAI-sublime-text
First class Sublime Text AI assistant with gpt-5, Opus 4.6, Gemini 3 and ollama support!
OpenAI Sublime Text Plugin
A Sublime Text extension that lets you talk to large language models (OpenAI, Anthropic, Google Gemini, or any OpenAI‑compatible service such as llama.cpp, Ollama, llmman) directly from the editor. It works at the cursor level, letting you send selected code, whole files, or diagnostic output and receive answers inline (as phantoms) or in a dedicated chat view.
Core Features
- Chat mode with any model you configure (including the experimental
gpt‑5). - Model‑agnostic: works with OpenAI, Anthropic Claude, Gemini, and any self‑hosted OpenAI‑compatible API.
- Project‑specific assistants – separate histories and settings per project.
- Context enrichment – attach whole files, build output, or LSP diagnostics to a request.
- Inline “phantom” UI – non‑intrusive answers appear right in the editor, with actions to copy, append, replace, open in a new tab, or save to history.
- Markdown rendering with syntax‑highlighted code blocks.
- Streaming (SSE) support, status‑bar token counters, and optional proxy configuration.
Installation
- Package Control (recommended):
- Open the command palette →
Package Control: Install Package→ typeOpenAI.
- Open the command palette →
- Manual:
- Open Preferences → Browse Packages.
- Run
git clone https://github.com/yaroslavyaroslav/OpenAI-sublime-text.git OpenAI\ completion. - Restart Sublime Text.
Tip: Install the Markdown editing packages linked in the README for a better experience.
Quick‑Start Usage
- Select text (optional) – the selection will be sent as part of the prompt.
- Open the command palette and run:
OpenAI: Chat Model Select– pick an assistant and output mode (inline Phantom or a chat View).OpenAI: New Message– send a prompt using the last‑used assistant.
- Type your prompt in the multiline input panel (⌘ Enter / Ctrl Enter to submit).
- View the response:
- Inline phantom overlay, or
- Dedicated chat tab (
OpenAI: Open in Tab).
Extra context commands – prepend recent build output or LSP diagnostics with the … With Build Output / … With LSP Output variants.
Configuration
- Settings file (
Preferences → Package Settings → OpenAI completion):{ "token": "sk‑your‑token", "proxy": {"address":"127.0.0.1","port":9898,"username":"account","password":"sOmEpAsSwOrD"}, "advertisement": false } - Define per‑assistant blocks to set
url,api_type,chat_model, and optionaltoken. - Use
ai_assistant.cache_prefixin a project’s.sublime‑projectto keep separate histories. - Toggle files for context via the command palette, tab context menu, or sidebar menu (
OpenAI: Add File to Context).
Requirements
- Sublime Text build 4205+ (Python 3.14 plugin host). Older builds (4050‑4204) are supported via the frozen 6.1.0 release line (Python 3.8).
- An API key for the chosen provider or a locally running compatible server (llama.cpp, Ollama, llmman, etc.).
Development & Extensibility
- UI components are vendored from the separate sublime‑chat‑ui repo; update with
./scripts/update_sublime_chat_ui.sh <ref>. - Contributions are welcome via pull requests.
Disclaimer
All selected code is transmitted to the configured LLM service. Ensure you have permission to share any proprietary code.
Bottom line: This plugin turns Sublime Text into an AI‑powered coding assistant, letting you query models, get inline suggestions, and keep project‑scoped chat histories without leaving the editor.
Related
- Project
- Project
- Project
- Project
- Project