Skip to content
CodeCompanion.nvim logo

CodeCompanion.nvim via Tokonomix

Extend CodeCompanion’s openai_compatible adapter to Tokonomix — 130+ models and consensus on one key, for chat and inline edits in Neovim.

openai_compatible HTTP adapterNeovim pluginMIT · open sourceNeovim
CodeCompanion.nvim — AI chat and inline-edit for Neovim, via Tokonomix

What is CodeCompanion.nvim?

CodeCompanion.nvim is an AI plugin for Neovim — chat and inline edits without leaving the editor. It ships an openai_compatible HTTP adapter you can extend to any base URL, which is exactly how Tokonomix plugs in.

  • Adds an AI chat buffer and inline-edit actions inside Neovim.
  • Extend the built-in openai_compatible adapter with { env = { url, api_key, chat_url } }.
  • Set the default model in the adapter’s schema.
  • Open source; configured in Lua.

Why route CodeCompanion.nvim through Tokonomix?

  • One adapter, 130+ models powering both chat and inline edits in Neovim.
  • Use tokonomix-consensus as a safety-net before accepting a diff; a direct slug for everyday turns.
  • Per-call spend caps bound usage; region / origin routing keeps repo data compliant.
  • Cost is metered to the cent in your Tokonomix dashboard.

Connect Tokonomix to CodeCompanion.nvim

In your Neovim config, extend the openai_compatible HTTP adapter with the Tokonomix URL, key and a default model.

require("codecompanion").setup({
  adapters = {
    http = {
      tokonomix = function()
        return require("codecompanion.adapters").extend("openai_compatible", {
          env = {
            url = "https://tokonomix.ai",
            api_key = "tok_live_your-key",
            chat_url = "/api/v1/chat/completions",
          },
          -- Opt-in (planning/review only, no tool-calling): default = "tokonomix-consensus"
          schema = { model = { default = "anthropic/claude-sonnet-4-6" } },
        })
      end,
    },
  },
})

Verify it works

  • Add the adapter to your Neovim config and select it as CodeCompanion’s provider.
  • Open the chat buffer or run an inline edit on a small change.
  • Confirm the call and token usage in your Tokonomix dashboard.

Model selection

Which model and endpoint should my agent use?

Pick by what your agent does, then swap the model id any time — every model in the catalog works through the same key.

What your agent doesUse this
Edits files / calls tools and streams responses (most coding agents)An Anthropic model via the Anthropic endpoint (tools + streaming both work)
Calls tools but does not need streaming (any model)The OpenAI-compatible endpoint with a single model id
Wants tools and streaming on a non-Anthropic modelRun non-streaming for now — streaming tool-calls on other providers is not enabled yet
Plain chat, no toolsEither endpoint; streaming is fine
Wants a cross-model verdict (consensus) on a high-stakes answerSet model to tokonomix-consensus on the OpenAI-compatible endpoint — note: consensus rejects tool requests (no tool-calling)
Endpoint & API reference (technical)

anthropic-messages → https://tokonomix.ai/api/anthropic — tools ✓, streaming ✓ (use an Anthropic model). openai-completions → https://tokonomix.ai/api/v1 — tools ✓ (single-model passthrough), streaming with tools not yet enabled. Plain chat: streaming works on both. Consensus: openai-completions, model tokonomix-consensus, no tools. Swap the model id to any slug returned by GET /api/v1/models.

Browse all models →

Related agents