---
url: 'https://docs.byesu.com/en/clients/neovim.md'
description: >-
  Connect Neovim (avante.nvim and codecompanion.nvim) to byesu API with
  lazy.nvim Lua configs: run Claude 5.5, GPT-6.2, and DeepSeek V4 with 0.1x
  caching.
---

# Connect Neovim (`avante.nvim` & `codecompanion.nvim`) to byesu API

> **Key Takeaways**
>
> * **`avante.nvim` native Claude (`0.1x` cache reads)**: Set `providers.claude = { endpoint = "https://byesu.com", model = "claude-sonnet-5-5", api_key_name = "BYESU_API_KEY" }` (**without `/v1`**).
> * **`avante.nvim` OpenAI-compatible (`providers` / `vendors`)**: Inherit from `"openai"` with `endpoint = "https://byesu.com/v1"` for `gpt-6.2-sol`, `deepseek-v4-pro`, and `gemini-4-argon`.
> * **`codecompanion.nvim` HTTP adapters**: Extend `"anthropic"` with `url = "https://byesu.com/v1/messages"`, and extend `"openai_compatible"` with `env = { url = "https://byesu.com", chat_url = "/v1/chat/completions", api_key = "BYESU_API_KEY" }`.
> * **One key, pay-as-you-go**: A single default **`auto`** group `sk-...` key unlocks Claude 5.5, GPT-6.2, Gemini 4, and DeepSeek V4 at a fraction of list rates, funded via USDT or Alipay.

**Neovim** pairs sub-millisecond modal editing with two standout AI plugins: **`avante.nvim`** (Cursor-style sidebar diffs and inline buffer patching) and **`codecompanion.nvim`** (buffer-native chat, slash commands, MCP tools, and inline transformations). Connecting either plugin to **[byesu](https://byesu.com)** gives you native Anthropic `/v1/messages` (`0.1x` prompt caching) alongside `/v1/chat/completions` inside clean `lazy.nvim` Lua specs.

::: tip Exact URL matrix across Neovim plugins
| Plugin & Adapter | Exact Endpoint / URL Config | Wire Protocol |
| --- | --- | --- |
| `avante.nvim` (`providers.claude`) | `endpoint = "https://byesu.com"` *(no `/v1`)* | Native `/v1/messages` + `0.1x` cache |
| `avante.nvim` (`__inherited_from = "openai"`) | `endpoint = "https://byesu.com/v1"` *(or custom `vendors`)* | OpenAI `/v1/chat/completions` |
| `codecompanion.nvim` (`extend("anthropic")`) | `url = "https://byesu.com/v1/messages"` | Native `/v1/messages` + `0.1x` cache |
| `codecompanion.nvim` (`extend("openai_compatible")`) | `url = "https://byesu.com"` + `chat_url = "/v1/chat/completions"` | OpenAI `/v1/chat/completions` |
:::

## Step 0: Export `BYESU_API_KEY` & Run the 5-Second Smoke Test

Create an `sk-...` token in the [byesu Console](https://byesu.com/register) under the default **`auto`** group ([Quickstart](/en/guide/quickstart)), export `BYESU_API_KEY` in `~/.zshrc` or `~/.bashrc` so Neovim never stores plaintext secrets in your dotfiles repo, and run the 5-second smoke test:

```bash
export BYESU_API_KEY="sk-your-byesu-token"
curl -fsSL https://docs.byesu.com/setup/test.sh | sh
```

*(Non-interactive shells: `BYESU_KEY="$BYESU_API_KEY" curl -fsSL https://docs.byesu.com/setup/test.sh | bash`.)* You can also generate custom Lua blocks in the **[Client & SDK Config Generator](/en/tools/config-generator)**.

## Setup 1: `avante.nvim` (`lazy.nvim` Complete Lua Spec)

Save the spec below to `~/.config/nvim/lua/plugins/avante.lua`. It wires [`claude-sonnet-5-5`](/en/models/claude-sonnet-5-5) as your default native Anthropic sidebar engine (`0.1x` cached reads) while registering [`claude-opus-5-5`](/en/models/claude-opus-5-5), [`gpt-6.2-sol`](/en/models/gpt-6-2), and [`deepseek-v4-pro`](/en/models/deepseek-v4) for instant `:AvanteSwitchProvider` switching:

```lua
-- ~/.config/nvim/lua/plugins/avante.lua
return {
  "yetone/avante.nvim",
  event = "VeryLazy",
  version = false,
  build = "make",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
    "nvim-tree/nvim-web-devicons",
  },
  opts = {
    provider = "claude",
    providers = {
      -- 1. Native Anthropic (/v1/messages appended automatically — NO /v1 suffix!)
      claude = {
        endpoint = "https://byesu.com",
        model = "claude-sonnet-5-5",
        api_key_name = "BYESU_API_KEY",
        timeout = 120000,
        extra_request_body = {
          max_tokens = 24000,
        },
      },
      -- 2. Claude Opus 5.5 for multi-file architecture & deep reasoning
      byesu_opus = {
        __inherited_from = "claude",
        endpoint = "https://byesu.com",
        model = "claude-opus-5-5",
        api_key_name = "BYESU_API_KEY",
        timeout = 180000,
        extra_request_body = {
          max_tokens = 32000,
        },
      },
      -- 3. OpenAI-compatible GPT-6.2 Sol (includes /v1)
      byesu_gpt = {
        __inherited_from = "openai",
        endpoint = "https://byesu.com/v1",
        model = "gpt-6.2-sol",
        api_key_name = "BYESU_API_KEY",
        timeout = 180000,
        extra_request_body = {
          max_completion_tokens = 32768,
        },
      },
      -- 4. High-throughput DeepSeek V4 Pro
      byesu_deepseek = {
        __inherited_from = "openai",
        endpoint = "https://byesu.com/v1",
        model = "deepseek-v4-pro",
        api_key_name = "BYESU_API_KEY",
        timeout = 120000,
        extra_request_body = {
          max_tokens = 16384,
        },
      },
    },
  },
}
```

::: info Using an older `avante.nvim` release (`vendors` table)?
Prior to `avante.nvim`'s unified `opts.providers` migration, custom OpenAI-compatible entries lived under `opts.vendors = { byesu_gpt = { __inherited_from = "openai", endpoint = "https://byesu.com/v1", model = "gpt-6.2-sol", api_key_name = "BYESU_API_KEY" } }` (or raw vendor handlers pointing directly at `"https://byesu.com/v1/chat/completions"`). Run `:Lazy update avante.nvim` to use the unified `opts.providers` schema above.
:::

## Setup 2: `codecompanion.nvim` (`lazy.nvim` Complete Lua Spec)

Save the spec below to `~/.config/nvim/lua/plugins/codecompanion.lua`. It configures **both** the native `anthropic` HTTP adapter (for `0.1x` cached Claude buffers) and `openai_compatible` (for GPT-6.2, DeepSeek V4, and Gemini 4):

```lua
-- ~/.config/nvim/lua/plugins/codecompanion.lua
return {
  "olimorris/codecompanion.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
  },
  opts = function()
    local adapters = require("codecompanion.adapters")

    return {
      strategies = {
        chat = { adapter = "byesu_claude" },
        inline = { adapter = "byesu_claude" },
        cmd = { adapter = "byesu_openai" },
      },
      adapters = {
        http = {
          -- Native Anthropic /v1/messages adapter (preserves 0.1x prompt cache reads)
          byesu_claude = function()
            return adapters.http.extend("anthropic", {
              url = "https://byesu.com/v1/messages",
              env = {
                api_key = "BYESU_API_KEY",
              },
              schema = {
                model = {
                  default = "claude-sonnet-5-5",
                  choices = {
                    "claude-sonnet-5-5",
                    "claude-opus-5-5",
                    "claude-haiku-5-5",
                  },
                },
              },
            })
          end,

          -- OpenAI-compatible adapter for GPT-6.2, DeepSeek V4 & Gemini 4
          byesu_openai = function()
            return adapters.http.extend("openai_compatible", {
              env = {
                url = "https://byesu.com",
                api_key = "BYESU_API_KEY",
                chat_url = "/v1/chat/completions",
                models_endpoint = "/v1/models",
              },
              schema = {
                model = {
                  default = "gpt-6.2-sol",
                  choices = {
                    "gpt-6.2-sol",
                    "deepseek-v4-pro",
                    "deepseek-v4.1-flash",
                    "gemini-4-argon",
                  },
                },
              },
            })
          end,
        },
      },
    }
  end,
}
```

*(On older `codecompanion.nvim` versions prior to `adapters.http`, place `byesu_claude` and `byesu_openai` directly under `adapters = { ... }` and call `adapters.extend(...)`.)* Inside any `:CodeCompanionChat` buffer, press `ga` to swap adapters or models on the fly.

## Common Neovim Pitfalls & Fixes

### 1. `/v1` vs `/v1/messages` Endpoint Mismatch (`HTTP 404`)

* In **`avante.nvim`**, `providers.claude` appends `/v1/messages` internally — setting `endpoint = "https://byesu.com/v1"` hits `/v1/v1/messages` (`404`). Keep `endpoint = "https://byesu.com"`.
* In **`codecompanion.nvim`**, `extend("anthropic", ...)` expects the full path `url = "https://byesu.com/v1/messages"`, while `extend("openai_compatible", ...)` combines `env.url` (`"https://byesu.com"`) + `env.chat_url` (`"/v1/chat/completions"`). See [Claude 404 model/path fix](/en/errors/claude-api-model-not-found-404).

### 2. `max_tokens` vs `thinking` Budget & `temperature` in `avante.nvim` (`HTTP 400`)

* **Omit fixed `temperature`**: Older `avante.nvim` configs pass `temperature = 0` inside `extra_request_body`. Claude 5.5 (`2026-10-21`) and `gpt-6.2-sol` reject fixed sampling parameters with HTTP `400` ([Claude 400 temperature fix](/en/errors/claude-api-400-temperature-top-p-not-supported)). If an older Avante preset injects `temperature`, set `temperature = nil` or upgrade `avante.nvim`.
* **Size `max_tokens` above `thinking.budget_tokens`**: When enabling Claude thinking blocks (`thinking = { type = "enabled", budget_tokens = 16000 }` or adaptive thinking), Anthropic requires `max_tokens > budget_tokens` (for example `max_tokens = 32000`) — otherwise `/v1/messages` rejects the call with HTTP `400` ([Claude max\_tokens fix](/en/errors/claude-api-400-max-tokens-too-large)).

### 3. `401 authentication_error` When Launching Neovim from GUI / Tmux

* Confirm `:lua print(os.getenv("BYESU_API_KEY"))` inside Neovim prints your `sk-...` key — detached `tmux` sessions started before editing `~/.zshrc` will not inherit new exports until sourced ([Claude 401 fix](/en/errors/claude-api-401-authentication-error)). Top up your pay-as-you-go balance anytime via **[USDT](/en/guide/pay-with-usdt)** or **Alipay**, and read **[Prompt Caching, Explained](/en/guide/prompt-caching)** to maximize `0.1x` cached buffer reads.

## FAQ

### What endpoint URL should I set for Claude in `avante.nvim` vs `codecompanion.nvim`?

Set `endpoint = "https://byesu.com"` (**no `/v1`**) in `avante.nvim`'s `claude` provider, and set `url = "https://byesu.com/v1/messages"` in `codecompanion.nvim`'s `anthropic` adapter.

### How do I add GPT-6.2 and DeepSeek V4 alongside Claude in `avante.nvim`?

Define entries under `opts.providers` with `__inherited_from = "openai"`, `endpoint = "https://byesu.com/v1"`, and `api_key_name = "BYESU_API_KEY"`, then switch with `:AvanteSwitchProvider`.

### Why does `avante.nvim` return HTTP `400` regarding `temperature` or `max_tokens` vs `thinking` budget?

Remove hardcoded `temperature` values for Claude 5.5 and GPT-6.2 reasoning models, and ensure `max_tokens` (`24000`–`32000`) strictly exceeds any `thinking.budget_tokens` value.

### How do I configure `codecompanion.nvim` `openai_compatible` adapter for byesu?

Extend `"openai_compatible"` with `env = { url = "https://byesu.com", api_key = "BYESU_API_KEY", chat_url = "/v1/chat/completions", models_endpoint = "/v1/models" }`.

## Related Guides & Tools

* [Connect Zed Editor to byesu API](/en/clients/zed)
* [Connect Block Goose CLI & Desktop to byesu API](/en/clients/goose)
* [Connect OpenHands Autonomous SWE Agent to byesu API](/en/clients/openhands)
* [Prompt Caching, Explained (`0.1x` Cache Reads)](/en/guide/prompt-caching)
* [AI Client & SDK Config Generator](/en/tools/config-generator)
* [Pay for Claude & GPT API with USDT](/en/guide/pay-with-usdt)
