Skip to main content
GitHub Copilot integration allows you to use your Copilot subscription with Avante.nvim. This provider leverages your existing Copilot authentication from copilot.lua or copilot.vim.

Prerequisites

You must have either copilot.lua or copilot.vim installed and authenticated before using this provider.

Quick Start

1

Install Copilot plugin

Choose one:copilot.lua (recommended):
{
  "zbirenbaum/copilot.lua",
  config = function()
    require("copilot").setup()
  end,
}
copilot.vim:
Plug 'github/copilot.vim'
2

Authenticate with GitHub Copilot

Follow the authentication flow in your Copilot plugin (usually :Copilot setup or similar).
3

Configure Avante

{
  "yetone/avante.nvim",
  dependencies = {
    "zbirenbaum/copilot.lua",
  },
  opts = {
    provider = "copilot",
  },
}

Configuration

Basic Configuration

providers = {
  copilot = {
    endpoint = "https://api.githubcopilot.com",
    model = "gpt-4o-2024-11-20",
    timeout = 30000,
    context_window = 64000,
    extra_request_body = {
      max_tokens = 20480,
    },
  },
}

Available Models

Copilot provides access to various models. You can list available models:
:lua print(vim.inspect(require('avante.providers').copilot:list_models()))
Common models:
providers = {
  copilot = {
    model = "gpt-4o-2024-11-20",
  },
}

Authentication

OAuth Token Location

Copilot authentication is stored in:
  • copilot.lua: ~/.config/github-copilot/hosts.json
  • copilot.vim: ~/.config/github-copilot/apps.json

Token Refresh

Tokens are automatically refreshed:
  • Refreshed 2 minutes before expiration
  • Background refresh every 28 minutes
  • Stored in ~/.local/share/nvim/avante/github-copilot.json

Manual Refresh

If you need to re-authenticate:
  1. Re-authenticate with your Copilot plugin
  2. Restart Neovim
  3. Avante will automatically pick up the new token

Response API

Copilot supports OpenAI’s Response API for certain models:
providers = {
  copilot = {
    -- Automatically enabled for gpt-5-codex models
    use_response_api = function(opts)
      local model = opts.model
      return model and model:match("gpt%-5%-codex") ~= nil
    end,
  },
}

Response API Features

  • Encrypted reasoning: Reasoning content is encrypted
  • Function calling: Enhanced tool use
  • Full history: Copilot doesn’t support previous_response_id, always sends full conversation
Unlike OpenAI’s Response API, Copilot requires sending the full conversation history with each request.

Model Listing

List available Copilot models:
local models = require('avante.providers').copilot:list_models()
for _, model in ipairs(models) do
  print(string.format("%s (%s)", model.display_name, model.id))
end
Model information includes:
  • id: Model identifier
  • display_name: Human-readable name
  • name: Full model name with provider
  • tokenizer: Tokenizer used
  • max_input_tokens: Maximum input size
  • max_output_tokens: Maximum output size
  • version: Model version

Advanced Configuration

Custom Endpoint

providers = {
  copilot = {
    endpoint = "https://api.githubcopilot.com",
  },
}

Proxy Configuration

providers = {
  copilot = {
    proxy = "http://proxy.example.com:8080",
    allow_insecure = false,
  },
}

Request Headers

Copilot uses specific headers for authentication:
-- Automatically set by Avante:
headers = {
  ["Authorization"] = "Bearer <token>",
  ["User-Agent"] = "GitHubCopilotChat/0.26.7",
  ["Editor-Version"] = "vscode/1.105.1",
  ["Editor-Plugin-Version"] = "copilot-chat/0.26.7",
  ["Copilot-Integration-Id"] = "vscode-chat",
  ["Openai-Intent"] = "conversation-edits",
}

Troubleshooting

If Copilot authentication fails:
  1. Verify Copilot plugin is installed:
    :Copilot status
    
  2. Re-authenticate with Copilot:
    :Copilot setup
    
  3. Check OAuth token exists:
    cat ~/.config/github-copilot/hosts.json
    
Tokens are auto-refreshed, but if you see expiration errors:
  1. Restart Neovim to trigger token refresh
  2. Re-authenticate with Copilot if needed
  3. Check token file: ~/.local/share/nvim/avante/github-copilot.json
If a model isn’t available:
  1. List available models:
    :lua print(vim.inspect(require('avante.providers').copilot:list_models()))
    
  2. Ensure you’re using a valid model ID
  3. Check your Copilot subscription includes the model
Error: “You must setup copilot with either copilot.lua or copilot.vim”
  1. Install copilot.lua or copilot.vim
  2. Authenticate with the plugin first
  3. Restart Neovim

Limitations

  • Cost: While included with Copilot subscription, be mindful of usage
  • Rate limits: Subject to Copilot’s rate limits
  • Auto-suggestions: Not recommended as auto_suggestions_provider due to high frequency (#1048)

Best Practices

Subscription

  • Requires active Copilot subscription
  • Individual or Business plans supported
  • Check limits in GitHub settings

Model Selection

  • Default models work well
  • Codex models for code-focused tasks
  • List models to see what’s available

Token Management

  • Tokens auto-refresh every 28 min
  • Check vim.g.avante_login for status
  • Re-auth if problems persist

Integration

  • Works alongside Copilot plugin
  • Shares authentication
  • Independent model selection

Example Configurations

{
  provider = "copilot",
  dependencies = {
    "zbirenbaum/copilot.lua",
  },
  providers = {
    copilot = {
      model = "gpt-4o-2024-11-20",
      timeout = 30000,
      extra_request_body = {
        max_tokens = 20480,
      },
    },
  },
}

Build docs developers (and LLMs) love