Neovim Hooks
Akto Guardrails for Neovim provides security validation and observability for AI plugin interactions directly inside Neovim. It intercepts LLM API calls made by Neovim AI plugins, validates prompts against security policies, blocks risky behavior, and reports all events to your Akto dashboard — without proxying or redirecting traffic.
Key Features
✅ Zero Proxy - Plugins always talk to LLM APIs directly; no traffic redirection
✅ Broad Plugin Coverage - Covers 7 major Neovim AI plugins out of the box
✅ Transparent Integration - Hooks into each plugin's native HTTP/LSP mechanism
✅ Real-time Protection - Blocks prompts before they reach the LLM in sync mode
✅ Centralized Monitoring - All events reported to Akto dashboard
✅ Flexible Deployment - Sync (blocking) or async (observability) modes
✅ Selective Coverage - Enable or disable hooks per plugin
Supported Plugins
avante.nvim
17.7k
plenary_hook
Wraps plenary.curl
copilot.vim
11.5k
copilot_vim_hook
Wraps _copilot.lsp_request
codecompanion.nvim
6.4k
plenary_hook
Wraps plenary.curl
windsurf.vim
5.1k
windsurf_hook
Wraps vim.fn.jobstart + chansend
copilot.lua
4.0k
copilot_hook
Wraps copilot.api.request
ChatGPT.nvim
4.0k
plenary_hook
Wraps plenary.job
CopilotChat.nvim
3.6k
plenary_hook
Wraps plenary.curl
How It Works
The Akto Neovim plugin wraps the HTTP and LSP functions each AI plugin uses internally. When a plugin makes an LLM API call:
Two Operating Modes:
Sync mode (
sync_mode = true, default) — Guardrails run before the LLM call. Blocked prompts never reach the LLM. Adds latency equal to the guardrails check.Async mode (
sync_mode = false) — LLM call goes through immediately. Guardrails and ingestion happen asynchronously after the call. Best for observability without blocking.
Monitored LLM APIs:
The plenary hook intercepts calls to the following API hosts:
api.openai.comapi.anthropic.comgenerativelanguage.googleapis.comapi.cohere.aiapi.mistral.aiapi.groq.comopenrouter.ai
File Structure
Key Files:
init.lua: Entry point —require("akto").setup(...)configures and activates all hookshttp.lua: Shared payload builder and Akto API communication; used by all hook modulesplenary_hook.lua: Interceptsplenary.curl(avante, codecompanion, CopilotChat) andplenary.job(ChatGPT.nvim); supports both sync and async modescopilot_hook.lua: Interceptscopilot.api.requestfor copilot.lua; ingestion-onlycopilot_vim_hook.lua: Intercepts_copilot.lsp_requestfor copilot.vim; ingestion-onlywindsurf_hook.lua: Interceptsvim.fn.jobstart+chansendfor Codeium/windsurf.vim; ingestion-onlyevents.lua: Registers autocmd listeners for plugin-level events (CodeCompanion, CopilotChat, avante)
Setup Guide
Prerequisites
Neovim 0.9+
curlon PATH (used for Akto backend calls)Akto instance running and accessible (e.g.
https://your-akto-instance.com)
Installation Steps
Create Plugin Directory
Download Plugin Files
Add to Your Neovim Config
Add the following to your ~/.config/nvim/init.lua after your plugin manager setup:
require("akto").setup(...) must be called after your plugin manager loads plugins so that the AI plugin modules are available for wrapping.
Configure Hook Behavior (Optional)
Customize which hooks are active and how they behave:
Mode Options:
sync_mode = true(default): Guardrails check runs synchronously before LLM call. Blocked prompts never reach the LLM.sync_mode = false: LLM call proceeds immediately. Guardrails and ingestion happen asynchronously. Use for observability without blocking.
Restart Neovim
On startup you should see a notification:
Verify Installation
Run the status command inside Neovim:
Expected output:
Test by using any supported AI plugin. Akto will validate the prompt and ingest the interaction.
Configuration Reference
Setup Options
Disabling Specific Hooks
Neovim Commands
:AktoEnable
Enable all hooks (re-enables after :AktoDisable)
:AktoDisable
Disable all hooks, restoring original plugin functions
:AktoStatus
Show current state, mode, and per-hook configuration
Hook Behavior by Plugin
avante.nvim
plenary_hook
✅ (sync mode)
✅
codecompanion.nvim
plenary_hook
✅ (sync mode)
✅
CopilotChat.nvim
plenary_hook
✅ (sync mode)
✅
ChatGPT.nvim
plenary_hook
✅ (sync mode)
✅
copilot.lua
copilot_hook
❌ (ingestion only)
✅
copilot.vim
copilot_vim_hook
❌ (ingestion only)
✅
windsurf.vim
windsurf_hook
❌ (ingestion only)
✅
Note: copilot.lua, copilot.vim, and windsurf.vim hooks intercept at the LSP/process level and operate in ingestion-only mode regardless of
sync_mode.
Troubleshooting
Plugin Not Loading
No Events in Dashboard
Hook Not Intercepting Calls
Ensure require("akto").setup(...) is called after your plugin manager loads AI plugins. If a plugin was already loaded before setup, run :AktoDisable then :AktoEnable to re-wrap.
Blocked Requests Not Showing Notification
Ensure events = true in your setup config. The autocmd listeners register block notifications for CodeCompanion, CopilotChat, and avante.
Slow Response / High Latency
Switch to async mode to remove guardrails latency from the LLM call path:
Uninstallation
To completely remove Akto Neovim hooks:
Complete Removal
Selective Removal (Keep Files, Disable)
Add enabled = false or simply remove the setup call from your config. The plugin files remain on disk but are not loaded.
Alternatively, use the Neovim command while running:
This restores all original plugin functions for the current session without removing files.
Backup Before Removal
Verify Removal
Restore to Default
After uninstallation, all AI plugins will operate without Akto security monitoring. No additional configuration is needed beyond removing the files and the setup call.
Enterprise Deployment
Automated Deployment Script
Deploy to developers:
Quick Setup Summary
Resources
Support: [email protected]
Community: https://www.akto.io/community
Last updated