Skip to main content
Avante.nvim provides a comprehensive Lua API for programmatic control and integration.

Module: avante

Main module accessible via require('avante').

setup(opts)

Initialize Avante.nvim with configuration options. Parameters: Example:
Source: lua/avante/init.lua:489-572

get(current)

Get the current sidebar, selection, and suggestion instances for the active tab. Parameters:
  • current (boolean|nil) - If false, doesn’t update the global current state (default: true)
Returns:
  • sidebar (avante.Sidebar) - Current sidebar instance
  • selection (avante.Selection) - Current selection instance
  • suggestion (avante.Suggestion) - Current suggestion instance
Example:
Source: lua/avante/init.lua:378-390

toggle()

Toggle the Avante sidebar visibility. Returns:
  • boolean - true if sidebar is now open, false if closed
Example:
Source: lua/avante/init.lua:417-430

toggle_sidebar(opts)

Toggle sidebar with options. Parameters:
  • opts (AskOptions|nil) - Options for sidebar behavior
Example:
Source: lua/avante/init.lua:417-430

is_sidebar_open()

Check if the sidebar is currently open. Returns:
  • boolean - true if sidebar is open
Example:
Source: lua/avante/init.lua:432-436

open_sidebar(opts)

Open the Avante sidebar. Parameters:
  • opts (AskOptions|nil) - Options for opening
Example:
Source: lua/avante/init.lua:439-446

close_sidebar()

Close the Avante sidebar. Example:
Source: lua/avante/init.lua:448-452

toggle.debug()

Toggle debug mode on/off. Example:
Source: lua/avante/init.lua:454-458

toggle.selection()

Toggle selection mode on/off. Example:
Source: lua/avante/init.lua:460-464

toggle.suggestion()

Toggle auto-suggestions on/off. Example:
Source: lua/avante/init.lua:466-479

register_acp_client(client_id, client)

Register an ACP (Agent Client Protocol) client for cleanup on exit. Parameters:
  • client_id (string) - Unique identifier for the client
  • client (any) - ACP client instance
Example:
Source: lua/avante/init.lua:31-34

unregister_acp_client(client_id)

Unregister an ACP client. Parameters:
  • client_id (string) - Unique identifier for the client
Example:
Source: lua/avante/init.lua:37-41

cleanup_all_acp_clients()

Cleanup all registered ACP clients (called automatically on exit). Example:
Source: lua/avante/init.lua:43-54

Module: avante.api

API module accessible via require('avante.api').

ask(opts)

Ask AI about code or start a chat session. Parameters:
  • opts (AskOptions|string|nil) - Options or question string
AskOptions fields:
  • question (string|nil) - Question to ask
  • win (table|nil) - Window options (similar to nvim_open_win)
  • ask (boolean|nil) - Enable ask mode (default: true)
  • floating (boolean|nil) - Use floating window for input
  • new_chat (boolean|nil) - Start new chat session
  • without_selection (boolean|nil) - Don’t include current selection
  • sidebar_pre_render (function|nil) - Callback before rendering
  • sidebar_post_render (function|nil) - Callback after rendering
  • project_root (string|nil) - Override project root
  • show_logo (boolean|nil) - Show Avante logo
Example:
Source: lua/avante/api.lua:132-186

zen_mode()

Open Avante in zen mode (full-screen chat experience). Example:
Source: lua/avante/api.lua:118-127, 129

edit(request, line1, line2)

Edit selected code block with AI assistance. Parameters:
  • request (string|nil) - Editing instruction
  • line1 (integer|nil) - Start line (from visual selection)
  • line2 (integer|nil) - End line (from visual selection)
Example:
Source: lua/avante/api.lua:191-200

refresh(opts)

Refresh Avante windows to sync with current buffer. Parameters:
  • opts (AskOptions|nil) - Refresh options
Example:
Source: lua/avante/api.lua:209-228

focus(opts)

Switch focus between sidebar and code window. Parameters:
  • opts (AskOptions|nil) - Focus options
Example:
Source: lua/avante/api.lua:231-255

build(opts)

Build Avante.nvim dependencies. Parameters:
  • opts (table|nil) - Build options
    • source (boolean) - Build from source (default: false)
Example:
Source: lua/avante/api.lua:47-104

switch_provider(target)

Switch the active AI provider. Parameters:
  • target (string) - Provider name (e.g., “claude”, “openai”, “gemini”)
Example:
Source: lua/avante/api.lua:33

switch_selector_provider(target_provider)

Switch the selector provider (e.g., telescope, fzf_lua). Parameters:
  • target_provider (string) - Selector provider name
Example:
Source: lua/avante/api.lua:15-21

switch_input_provider(target_provider)

Switch the input provider (native, dressing, snacks). Parameters:
  • target_provider (string) - Input provider name
Example:
Source: lua/avante/api.lua:24-30

select_model()

Open the model selector UI. Example:
Source: lua/avante/api.lua:257

select_history()

Open the chat history selector. Example:
Source: lua/avante/api.lua:259-273

add_buffer_files()

Add all open buffers to the selected files list. Example:
Source: lua/avante/api.lua:275-283

add_selected_file(filepath)

Add a specific file to the chat context. Parameters:
  • filepath (string) - Path to the file
Example:
Source: lua/avante/api.lua:285-295

remove_selected_file(filepath)

Remove a file or directory from the chat context. Parameters:
  • filepath (string) - Path to the file or directory
Example:
Source: lua/avante/api.lua:297-318

stop()

Stop the current AI request. Example:
Source: lua/avante/api.lua:320

get_suggestion()

Get the current suggestion instance. Returns:
  • avante.Suggestion|nil - Current suggestion instance
Example:
Source: lua/avante/api.lua:203-206

API Summary

Main Module (avante)

API Module (avante.api)