Blog6 min read

Use SolCard Inference in CodeCompanion.nvim

Add SolCard Inference to CodeCompanion in Neovim with an openai_compatible adapter: the Lua block, why url drops /v1, key options and fixes.

Contents

To use SolCard Inference in CodeCompanion.nvim, extend the openai_compatible adapter with url set to https://api.solcardinference.ai (no /v1), point api_key at an environment variable holding your sk-si- key, and list our three models as choices. Every CodeCompanion setting below comes from its OpenAI-compatible providers guide and HTTP adapters page. We haven’t run it ourselves.

What you need

  • A SolCard Inference API key. Create one on the dashboard’s API keys page. Keys start with sk-si- and are shown once.
  • Some balance or a plan. One prepaid USD balance pays for chat, every key and every model; see how billing works.
  • Neovim with CodeCompanion installed.

The adapter

Put this in your CodeCompanion setup:

require("codecompanion").setup({
  adapters = {
    http = {
      solcard_inference = function()
        return require("codecompanion.adapters").extend("openai_compatible", {
          formatted_name = "SolCard Inference",
          env = {
            url = "https://api.solcardinference.ai",
            api_key = "SOLCARD_INFERENCE_API_KEY",
          },
          schema = {
            model = {
              default = "solcard-inference-fast",
              choices = {
                "solcard-inference-fast",
                "solcard-inference-large",
                "solcard-inference-base",
              },
            },
          },
          opts = {
            vision = false,
          },
        })
      end,
    },
  },
  interactions = {
    chat = {
      adapter = "solcard_inference",
    },
    inline = {
      adapter = "solcard_inference",
    },
  },
})

Then set the key where Neovim will see it:

export SOLCARD_INFERENCE_API_KEY=sk-si-...

What each part does:

SettingWhat it’s for
solcard_inferenceThe adapter’s name. interactions refers to it.
formatted_nameThe label in the chat header. Without it, the guide says you get “OpenAI Compatible”.
env.urlOur host, without /v1. See below.
env.api_keyThe name of the environment variable, not the key itself.
schema.model.defaultThe model a new chat starts on.
schema.model.choicesWhat the ga picker offers.
opts.visionOff, because our models take text only.
interactionsMakes the adapter the default for the chat buffer and the inline assistant.

Why the URL has no /v1

CodeCompanion splits the address into a host and a path, and the path already starts with /v1. The guide says url is the base URL without /v1, because the default chat_url (/v1/chat/completions) and models_endpoint (/v1/models) include it. So requests go to https://api.solcardinference.ai/v1/chat/completions, our Chat Completions endpoint.

This is the opposite of most tools. If you copy our usual base URL, https://api.solcardinference.ai/v1, into url, the path doubles to /v1/v1/chat/completions, which isn’t our endpoint. That’s the first thing to check when nothing works.

Why list the models

With default and choices both set, CodeCompanion never calls the models endpoint. Per the guide, without a model it takes the first one the models endpoint returns. That list is cached for 30 minutes. Set only default and the endpoint is still called when you open the picker.

Our API does have a models endpoint, but listing the three IDs keeps the picker to exactly what you can use. It also sidesteps a limit the guide names: “Every adapter built on openai_compatible shares one model cache.” If you also run LM Studio or a company gateway through the same adapter type, its models could show up under ours until the cache expires.

Keeping the key out of your config

api_key takes four forms. Per the HTTP adapters page, it can be an environment variable name, a cmd: shell command, a file: path, or a Lua function. A password manager works through cmd::

api_key = "cmd:op read op://personal/solcard-inference/credential --no-newline",

Commands time out after 20 seconds by default. Any other string is sent as is, so don’t paste the raw sk-si- key into a dotfiles repo.

Don’t leave api_key out. The guide says that without it, the adapter sends OPENAI_API_KEY. Your OpenAI key would go to our API and fail, and it shouldn’t leave your machine for the wrong host anyway.

Switching models

Press ga in the chat buffer to change adapter, and since our adapter has three models, CodeCompanion then asks which one, per its chat buffer docs. A sensible split is Fast for inline edits and quick questions, and Large in chat when a change needs planning. You can pin the inline assistant to one model with the table form the guide shows:

inline = {
  adapter = {
    name = "solcard_inference",
    model = "solcard-inference-fast",
  },
},

Large always reasons, so it writes more output tokens per answer. Fast, Large or Base compares the three.

An inline edit is cheap. Sending an 8,000-token file and getting 600 tokens back costs about $0.012 on Fast at our pay-as-you-go prices. Chat costs grow with the conversation, because each message resends the history.

Agent mode and tool approval

@{agent} gives the model tools that edit files and run commands, so keep approvals on. CodeCompanion’s agents and tools page lists create_file, delete_file, edit_file and run_command among the group’s tools, and says tools “use an LLM’s function calling ability.” Our Chat Completions endpoint accepts function tools, so leave opts.tools at its default.

The same page offers three approval modes, switched with gty: Ask, Auto and YOLO, which “runs every tool, including protected ones, without asking.” Our models have their refusal training removed, so they won’t push back on a destructive command the way a stock model might. That decision is yours: set approval_mode = "ask" and read each run_command before you press g2 to accept.

Troubleshooting

The codes are from our errors page; CodeCompanion may show them differently.

  • Requests fail right away: check url has no /v1.
  • 401 invalid_api_key: Neovim can’t see the variable, or the key was revoked. Start Neovim from a shell where echo $SOLCARD_INFERENCE_API_KEY prints it.
  • 400 model_not_found: a model ID is misspelled in default, choices or the inline table.
  • 400 unsupported_content: an image reached the API. Check opts.vision is false.
  • 402 insufficient_balance: credits and plan can’t cover the request. Top up and retry.
  • 429 plan_limit_reached: your plan’s weekly limit is used up. Wait for the reset or top up.

To see exactly what CodeCompanion sends, the guide says to set opts.log_level = "DEBUG", send a message, and run :checkhealth codecompanion to find the log file.

FAQ

Can I use the Responses API instead of Chat Completions? Our API speaks both. CodeCompanion’s guide says to extend openai rather than openai_compatible for a Responses server, and to set the full url, which for us is https://api.solcardinference.ai/v1/responses. This guide sticks to Chat Completions.

Does this replace my other CodeCompanion adapters? No. It adds one more under adapters.http. To list only your own adapters in the ga picker, the HTTP adapters page gives adapters.http.opts.show_presets = false.

Can I send images or files to the model? No. Our models take text only, and Base stops at 262k tokens of context, so very large buffers fit better on Fast or Large. Every model stops at 32,768 output tokens per request.

Are my prompts and code stored? Not by us. Prompts and responses are never logged or stored; keeps nothing follows one request through.

Is there a guide for another editor? Yes: Zed uses its own openai_compatible block in settings.json, and that one does keep /v1 in the URL.

Bring the prompt that got refused.

Private. No refusals. In the app, or in the tools you already use.

Pay in crypto. No KYC.