luaneovimneovim-plugincursor-ide

Avante plugin won't generate Responses


Problem: Avante plugin never responds with a generated response. It just hangs forever.

Suspicion: There is something wrong with the API key or way it is being used.

Question:

  1. How do I properly set and verify my API Key?
  2. How do I get Avante to respond with it's generated response; rather than hang forever.

Setup:

I copied the standard avante install with lazy to ~/.config/nvim/lua/plugins/avante' as shown below.

I pay for Claude. I created my anthropic api key by going to: https://console.anthropic.com/settings/keys and creating a new key.

I tried setting this key three ways:

  1. in ~/.config/fish/config.fish I added set -gx ANTHROPIC_API_KEY <MY-API-KEY>. I verified it was set by running source ~/.config/fish/config.fish then echo $ANTHROPIC_API_KEY.
  2. With no env var. I execute <leader>aa in neovim. I am prompted to enter ANTHROPIC_API_KEY by Avante and I enter my real api key.
  3. With no env var. I execute <leader>aa in neovim. I am prompted to enter ANTHROPIC_API_KEY by Avante and I enter my something random like: asdfasdfjkl.

Then I nvim index.js and <leader>aa to open Avante. I enter a prompt, eg. Write a Javascript function that takes in two arguments and returns their sum. then Ctrl-S and I see Generating response ... forever.

It never outputs anything. It just hangs here forever:

---

- Datetime: 2024-12-03 09:43:21

- Model: claude/claude-3-5-sonnet-20241022

- Selected file: index.js

> Write a Javascript function that takes in two arguments and returns their sum.

**Generating response ...**

All three produce the same result. It seems that my API key is incorrect because it behaves the same as when I give something random for the API keys.

return {
    "yetone/avante.nvim",
    event = "VeryLazy",
    lazy = false,
    version = false, -- set this if you want to always pull the latest change
    opts = {
        -- add any opts here
    },
    -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
    build = "make",
    -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
    dependencies = {
        "stevearc/dressing.nvim",
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",
        --- The below dependencies are optional,
        "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
        "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
        "zbirenbaum/copilot.lua", -- for providers='copilot'
        {
            -- support for image pasting
            "HakonHarnes/img-clip.nvim",
            event = "VeryLazy",
            opts = {
                -- recommended settings
                default = {
                    embed_image_as_base64 = false,
                    prompt_for_file_name = false,
                    drag_and_drop = {
                        insert_mode = true,
                    },
                    -- required for Windows users
                    use_absolute_path = true,
                },
            },
        },
        {
            -- Make sure to set this up properly if you have lazy=true
            "MeanderingProgrammer/render-markdown.nvim",
            opts = {
                file_types = { "markdown", "Avante" },
            },
            ft = { "markdown", "Avante" },
        },
    }
}

Solution

  • The issue was that I hadn't added credits to anthropic. I thought that since I was paying for "Professional" account with Claude.ai that this would work. It doesn't.

    Solution: I added credits to Anthropic and then cancelled my Claude.ai subscription.