Connect OpenRouter to VS Code

Compare models and prices, then call any of them with one key. Add Toolspoke to VS Code once and it can use 8 OpenRouter actions. Your OpenRouter credential stays in Toolspoke, and you choose which actions VS Code may call.

Set it up in VS Code

Three steps, the first one once for every toolkit you will ever add.

  1. Add Toolspoke to VS Code

    .vscode/mcp.json, or the MCP: Add Server command

    { "servers": { "toolspoke": { "type": "http", "url": "https://toolspoke.com/mcp" } } }

    Approve the authorization request when VS Code opens it.

  2. Install OpenRouter and connect it

    Add OpenRouter to a project in your Toolspoke workspace.

    API key. You provide it once, when you install the connector. Toolspoke encrypts it at rest and decrypts it only for the length of a single call, and the gateway attaches it to the outbound request itself, so it is never part of the arguments an agent sends.

    API key
    openrouter.ai → Keys. An inference key reaches the catalogue, key info, and chat_completion; get_credits additionally needs a management key.
  3. Choose what VS Code may do

    All 8 actions start on. Switch off the one action that changes something in OpenRouter, and VS Code gets a refusal if it tries.

What you can ask VS Code for

A few of the OpenRouter actions that only read, so they are safe to try first.

  • Fetch one model by its id, split into author and slug
  • Read the API key this connection uses: its label, spend limit, remaining limit, and usage to date
  • Read the account's total credits purchased and total credits used

What VS Code can do in OpenRouter

7 actions read and one writes.

Reads

  • List models

    Search the model catalogue and read each model's context length, per-token pricing, modalities, and the sampling parameters it supports. Call this before chat_completion when the model id is not already known, an id that is not in this list is refused. Prices are strings in US dollars per token.

  • Get model

    Fetch one model by its id, split into author and slug. Use it when list_models has already named the model and the full record is wanted, pricing, context length, modalities, and knowledge cutoff.

  • List model endpoints

    List every provider serving one model, with that provider's price, context limit, quantisation, uptime, latency, and throughput. This is how to choose a provider for chat_completion's `provider.order`, and how to explain why two calls to the same model differed in cost or speed.

  • List providers

    List the upstream providers OpenRouter can route to, with each one's privacy policy, terms, status page, headquarters country, and datacentre countries. Use it when a choice of provider has to satisfy a data-residency rule.

  • Get key

    Read the API key this connection uses: its label, spend limit, remaining limit, and usage to date. The cheapest proof that the credential works, and the way to check a limit before starting a long run. `rate_limit` is a legacy field OpenRouter always returns as -1, ignore it.

  • Get credits

    Read the account's total credits purchased and total credits used. Needs a management key, an ordinary inference key is refused with a 403, in which case use get_key, whose usage and limit fields answer most of the same questions.

  • Get generation

    Look up what one completed request actually cost and who served it, by the generation id returned in a chat_completion response. Gives total cost, the provider that answered, native prompt and completion token counts, cache discount, latency, and the finish reason. Statistics only, the prompt and completion text are not returned here.

Writes

  • Chat completion

    Run a chat completion against any model in the catalogue. This spends credits and is billed per token, so check pricing with list_models first and keep max_completion_tokens tight. Pass `models` to name fallbacks tried in order when the first is unavailable, and `provider` to constrain or rank which upstream serves the call. The response `id` is what get_generation reads to report the real cost.

OpenRouter in VS Code: questions

Does VS Code see my OpenRouter credential?

No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. VS Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.

Can I stop VS Code from changing things in OpenRouter?

Yes. Each of the 8 actions can be switched off for a project. Turn off the one that changes something and VS Code can only read.

Will 8 actions crowd VS Code's context?

No. Toolspoke shows VS Code five bridge tools, plus a guide where a toolkit has one, and VS Code searches for the OpenRouter action it needs when it needs it. Adding more toolkits does not add more tools to its list.

Where do the tools show up in VS Code?

In chat, in agent mode, which is where VS Code uses MCP servers. Add the block to .vscode/mcp.json for one workspace, or use the MCP: Add Server command.

What does it cost?

Tool calls are free on every plan, and a OpenRouter call does not run in a sandbox, so it bills nothing.

Try OpenRouter in VS Code

Free to start, and tool calls cost nothing on any plan.