AI IDE List
AI IDE List
Back to Blog
ArticleJuly 10, 202617

How to Implement AI in Sublime Text: Copilot, Claude, Codex, and Local Models

How to Implement AI in Sublime Text: Copilot, Claude, Codex, and Local Models
On This Page8 sections

Key Takeaways

Sublime Text can become an effective AI-assisted editor, but the AI layer is added through community packages or external coding agents rather than a first-party assistant. For fast inline suggestions, use LSP-copilot. For multi-provider chat and selected-file context, use OpenAI completion. For repository-wide edits and terminal actions, connect Claude Code or Codex through TermMate or a dedicated Codex package. Local models through Ollama, llama.cpp, or LM Studio provide the strongest privacy control.

Updated: July 10, 2026.

Does Sublime Text have built-in AI in 2026?

Sublime Text 4 does not include a first-party AI chat, coding agent, or Copilot-style completion service in its current stable release. AI functionality is supplied by packages that use the editor’s Python plugin API, completion system, command palette, panels, phantoms, and build integration.

This plugin-first model allows users to keep Sublime Text lightweight or install only the AI capabilities they need. AI features remain optional components rather than mandatory parts of the editor’s core interface.

What does “implement AI into Sublime Text” actually mean?

Implementing AI into Sublime Text means adding one or more of four distinct capabilities: inline completion, prompt-based code transformation, project-aware chat, and agentic execution. These are different workloads, so one package rarely provides the best experience across all four.

  • Inline completion predicts the next line, block, or function while typing.
  • Prompt actions explain, document, refactor, translate, or review selected code.
  • Project-aware chat adds chosen files, diagnostics, or build output to the model context.
  • Agentic execution lets an AI inspect files, edit multiple files, run commands, and iterate on test results.

The practical distinction is control. Completion tools react continuously and must be fast; chat tools should let the developer choose context; agent tools need explicit permissions, working-directory boundaries, approval rules, and a visible record of edits or commands.

Which Sublime Text AI integration should you choose?

The best integration depends on whether the priority is typing speed, provider choice, local inference, or autonomous repository work. The following comparison reflects the packages’ documented capabilities as of July 2026.

IntegrationPrimary useProvider modelProject contextCan run commands?Best fit
LSP-copilotInline completion and chatGitHub Copilot subscriptionLimited by Copilot and LSP workflowNo direct agent shellDevelopers who already use Copilot
OpenAI completionChat, inline phantoms, explain and refactorOpenAI, Anthropic, Gemini, Ollama, llama.cpp, compatible APIsSelected files, diagnostics, and build outputNo full autonomous shell loopMulti-model AI inside Sublime Text
CodeContinueLightweight inline completionOpenAI-compatible endpointsSurrounding lines and configurable contextNoLocal or hosted autocomplete
TermMateAgentic coding interfaceClaude Code, Codex, and compatible agentsRepository files and explicit referencesYes, subject to approval settingsMulti-file changes and command execution
Codex packageSublime interface for Codex CLICodex-supported models and providersSelected text and sandboxed repository accessYesCodex users who want approvals and transcripts

A useful architecture is to combine one low-latency completion tool with one deliberate agent tool. Running several completion packages simultaneously creates duplicate suggestions, keybinding conflicts, additional network requests, and unclear data flows without adding meaningful capability.

How do you install AI packages in Sublime Text?

AI packages are normally installed through Package Control, Sublime Text’s community package manager. Open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows and Linux, run Install Package Control if needed, then choose Package Control: Install Package and search for the package name.

Use this baseline sequence:

  1. Update to Sublime Text 4.
  2. Install or update Package Control.
  3. Install only one inline-completion package initially.
  4. Restart Sublime Text when the package requires it.
  5. Open the package settings and configure authentication or a local endpoint.
  6. Test the integration in a small, non-sensitive repository before enabling it for production work.

Package names matter. The working community package for GitHub Copilot integration is named LSP-copilot, rather than an official package simply called GitHub Copilot.

How do you add GitHub Copilot-style completion to Sublime Text?

LSP-copilot is the most direct route to GitHub Copilot completion in Sublime Text. It provides inline popup suggestions, inline phantoms, panel completion, and chat through GitHub’s Copilot language server, but it requires the Sublime LSP package, a network connection, and an active GitHub Copilot subscription.

Installation steps:

  1. Open Package Control: Install Package.
  2. Install LSP.
  3. Install LSP-copilot.
  4. Restart Sublime Text.
  5. Open a source file.
  6. Run Copilot: Sign In from the Command Palette.
  7. Complete GitHub’s device-code authentication flow.
  8. Open Preferences: LSP-copilot Settings to adjust automatic completion, telemetry, proxy, or debugging behavior.

LSP-copilot is the right choice when predictable inline completion matters more than provider flexibility. It is not the strongest choice for local models, custom API gateways, repository-wide tool execution, or teams that cannot send source context through a hosted Copilot service.

How do you add ChatGPT, Claude, Gemini, or Ollama to Sublime Text?

OpenAI completion is one of the broadest single-package options for multi-provider AI inside Sublime Text. Despite its name, the package supports OpenAI, Anthropic Claude, Google Gemini, Ollama, llama.cpp, and OpenAI-compatible services.

Install OpenAI completion through Package Control, then open its settings and create an assistant configuration for the chosen provider. The important fields are the endpoint, API type, model, and authentication token.

The package can send selected text, manually chosen files, build output, or LSP diagnostics as context. Responses can appear in a chat panel, a normal tab, or an inline phantom with actions to copy, append, or replace code. This explicit context model is safer and more predictable than silently indexing an entire repository.

How do you run a local AI model with Sublime Text?

A local model is implemented by running an inference server on the same machine or private network and pointing a Sublime Text package at its API endpoint. OpenAI completion supports local services, while CodeContinue accepts OpenAI-compatible endpoints and provides configurable context controls.

A practical local setup is:

text Sublime Text 4 → CodeContinue or OpenAI completion → http://localhost:<port>/v1/chat/completions → Ollama, llama.cpp, or LM Studio → a code-focused local model

CodeContinue is especially suitable when the goal is lightweight local autocomplete. Its configuration includes an endpoint, model name, optional API key, surrounding-line context, request timeout, and language allowlist. Its keybindings may need to be enabled manually to avoid conflicts with existing Sublime Text shortcuts.

Local inference reduces third-party data exposure but does not automatically guarantee privacy. Prompts can still be logged by a local gateway, reverse proxy, desktop model manager, or company observability system. Developers should inspect network traffic, model-server logs, crash reporting, and package behavior before treating the workflow as confidential.

How do you add Claude Code or Codex agent workflows?

Agentic coding is added by connecting Sublime Text to an external coding-agent CLI rather than relying only on a text-completion API. TermMate supports agent-oriented workflows, provides a native chat view, lets users reference files or line ranges, and exposes planning and approval controls for tool use.

The recommended TermMate workflow is:

  1. Install TermMate through Package Control.
  2. Install or authenticate a supported agent CLI.
  3. Run TermMate: Start Chat.
  4. Set the repository working directory.
  5. Reference files explicitly through the package interface.
  6. Use planning mode for large or risky changes.
  7. Keep approval mode enabled until the agent’s behavior is understood.
  8. Review diffs and run the project’s tests before committing.

A dedicated Codex package is a more focused alternative. It can launch the Codex app server, expose sandbox and approval controls in Sublime Text, support assistant-to-shell interaction, and record conversations in a Markdown panel or tab.

How do you build a custom AI plugin for Sublime Text?

A custom AI plugin is appropriate when a team needs fixed prompts, an internal gateway, proprietary authentication, strict context selection, or workflow-specific output handling. Sublime Text plugins are Python scripts built from command and event-listener classes, and the API can create panels, insert text, show phantoms, read selections, and run work asynchronously.

The following minimal plugin sends only the selected text to an OpenAI-compatible endpoint and opens the result in a new buffer:

`python import json import os import urllib.request import urllib.error

import sublime import sublime_plugin

class AiExplainCommand(sublime_plugin.TextCommand): def run(self, edit): selected = "\n".join( self.view.substr(region) for region in self.view.sel() if not region.empty() ).strip()

text
    if not selected:
        sublime.status_message("Select code before running AI Explain")
        return

    sublime.set_timeout_async(lambda: self._request(selected), 0)

def _request(self, selected):
    settings = sublime.load_settings("AI.sublime-settings")
    endpoint = settings.get(
        "endpoint",
        "http://127.0.0.1:11434/v1/chat/completions"
    )
    model = settings.get("model", "your-code-model")
    api_key = os.environ.get("SUBLIME_AI_API_KEY", "")

    payload = {
        "model": model,
        "messages": [
            {
                "role": "system",
                "content": "Explain the selected code. Identify defects and risks."
            },
            {"role": "user", "content": selected}
        ],
        "temperature": 0.1
    }

    headers = {"Content-Type": "application/json"}
    if api_key:
        headers["Authorization"] = f"Bearer {api_key}"

    request = urllib.request.Request(
        endpoint,
        data=json.dumps(payload).encode("utf-8"),
        headers=headers,
        method="POST"
    )

    try:
        with urllib.request.urlopen(request, timeout=60) as response:
            data = json.loads(response.read().decode("utf-8"))
            result = data["choices"][0]["message"]["content"]
    except (urllib.error.URLError, KeyError, ValueError) as exc:
        result = f"AI request failed: {exc}"

    sublime.set_timeout(lambda: self._show_result(result), 0)

def _show_result(self, result):
    window = self.view.window()
    if not window:
        return

    output = window.new_file()
    output.set_name("AI Explanation")
    output.set_scratch(True)
    output.run_command("append", {"characters": result})

`

Save the file under Packages/User/ai_explain.py, then add a command-palette entry in Packages/User/Default.sublime-commands:

json [ { "caption": "AI: Explain Selected Code", "command": "ai_explain" } ]

This design keeps the network request off Sublime Text’s UI thread, reads credentials from an environment variable, sends only selected code, uses a low temperature for deterministic review, and treats malformed responses as visible errors. Production versions should add cancellation, streaming, provider-specific response parsing, redaction rules, structured logging, retry limits, and tests.

New plugins should target Sublime Text’s modern Python plugin environment and avoid dependencies that assume the legacy Python runtime.

How should API keys and source code be protected?

AI integration should follow a least-context, least-permission model. The safest default is to send only selected code, exclude secrets and generated assets, keep agent write access inside the current repository, require confirmation for shell commands, and store credentials outside version-controlled project files.

Use these controls:

  • Keep API keys in environment variables or a local secret manager.
  • Never place live keys in .sublime-project, shared settings, screenshots, or committed dotfiles.
  • Exclude .env files, credentials, certificates, production configuration, and customer data from AI context.
  • Prefer explicit file selection over automatic whole-project context.
  • Use separate provider accounts or gateways for personal and company work.
  • Keep command approval enabled for agentic tools.
  • Review package source code, release history, dependencies, and requested permissions.
  • Rotate a key immediately when it appears in a prompt, transcript, build log, or repository.

The security boundary is defined by package configuration, provider policy, selected context, and agent permissions—not by Sublime Text alone.

What is the best Sublime Text AI configuration for each workflow?

The best configuration is the smallest stack that covers the actual workflow. More packages do not create a more capable editor when they duplicate completions, compete for shortcuts, or send the same context to several providers.

WorkflowRecommended setupReason
Fast daily coding with an existing Copilot planLSP + LSP-copilotLow-friction Copilot-style completion
Chat with several hosted model providersOpenAI completionOne interface for OpenAI, Claude, Gemini, and compatible APIs
Private or low-cost local completionCodeContinue + local OpenAI-compatible serverSimple endpoint and context controls
Multi-file feature workTermMate + Claude Code or CodexAgent planning, file access, edits, and command execution
Codex-centric workflowCodex package + Codex CLINative transcript, sandbox, approvals, and shell integration
Regulated internal environmentCustom plugin + company gatewayExplicit context, authentication, logging, and policy enforcement

For most developers, the balanced setup is LSP-copilot or CodeContinue for completion, plus TermMate or Codex for deliberate agent tasks. OpenAI completion can replace separate chat and prompt-action packages when multi-provider flexibility is more important than continuous autocomplete.

What problems commonly break Sublime Text AI integrations?

Most failures come from package naming, outdated dependencies, missing CLI binaries, authentication, endpoint incompatibility, or keybinding conflicts. Troubleshooting should begin with Sublime Text’s console and the package’s documented requirements rather than reinstalling the editor.

Check these items in order:

  1. Confirm the package supports Sublime Text 4.
  2. Restart after installing LSP-based or binary-backed packages.
  3. Open View > Show Console and inspect the first error rather than only the final cascade.
  4. Verify that the API endpoint includes the path expected by the package.
  5. Confirm that the configured model name exists on the server.
  6. Test the endpoint outside Sublime Text with a minimal request.
  7. Disable overlapping completion packages.
  8. Check proxy, TLS interception, firewall, and corporate allowlists.
  9. Verify the external agent CLI is installed and available in Sublime Text’s environment.
  10. Re-enable custom keybindings only after the default commands work.

Empty package lists and failed downloads are frequently caused by proxy, certificate, or network configuration problems. Package compatibility can also change after updates to Sublime Text, plugin hosts, model APIs, or external agent CLIs.

Is Sublime Text a real alternative to Cursor or VS Code for AI coding?

Sublime Text is a credible AI-assisted editor for developers who value speed, keyboard-driven workflows, explicit context, and modular tooling. It is not a feature-for-feature replacement for AI-native IDEs when the requirement is seamless repository indexing, integrated checkpoints, visual multi-file diffs, background agents, or centrally managed enterprise controls.

The main advantage is composability: completion, chat, local inference, and agent execution can be selected independently. The main disadvantage is integration cost: community packages may require manual configuration, external CLIs, separate authentication, compatibility checks, and more troubleshooting than a tightly integrated AI IDE.

A strong hybrid workflow keeps Sublime Text as the primary editor while running Claude Code, Codex, or another agent in a controlled repository workspace. This preserves Sublime Text’s responsiveness and editing model while delegating expensive project analysis and multi-file execution to tools designed for agentic work.

Conclusion

AI can be implemented in Sublime Text without turning the editor into a heavyweight AI IDE. Install LSP-copilot for GitHub Copilot completion, OpenAI completion for multi-provider chat and explicit file context, CodeContinue for lightweight local autocomplete, or TermMate and Codex for repository-level agent work.

Start with one completion package, add one agent only when multi-file automation is needed, and keep context and permissions narrow. The most reliable setup is not the package with the longest feature list; it is the setup whose data flow, model endpoint, working directory, approval rules, and failure modes are fully understood.

Share this article

Referenced Tools

Browse entries that are adjacent to the topics covered in this article.

Explore directory