KosmoKrator

ai

OpenRouter MCP Integration for Vercel AI SDK

Connect OpenRouter to Vercel AI SDK through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.

7 functions 6 read 1 write API key auth

Connect OpenRouter to Vercel AI SDK

Use KosmoKrator as a local integration gateway for Vercel AI SDK agents and scripts.

Create an MCP client that starts or connects to the KosmoKrator gateway for the selected integration. The gateway is local, scoped to this integration, and starts with --write=deny so Vercel AI SDK can inspect read-capable tools without receiving write access by default.

OpenRouter MCP Config for Vercel AI SDK

Prefer CLI JSON calls when a workflow only needs one deterministic integration operation.

{
  "mcpServers": {
    "kosmokrator-openrouter": {
      "type": "stdio",
      "command": "kosmo",
      "args": [
        "mcp:serve",
        "--integration=openrouter",
        "--write=deny"
      ]
    }
  }
}

Run the Gateway Manually

kosmokrator mcp:serve --integration=openrouter --write=deny

Why Use KosmoKrator Here

Scoped tools

Expose only OpenRouter instead of a broad multi-service tool list.

Local credentials

Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.

Write policy

Start read-only, then opt into ask or allow for trusted workspaces.

OpenRouter Tools Visible to Vercel AI SDK

Vercel AI SDK sees stable MCP tool names generated from the OpenRouter integration catalog.

MCP toolSource functionTypeDescription
integration__openrouter__openrouter_list_models openrouter.openrouter_list_models Read List available AI models on OpenRouter. Returns model identifiers, names, pricing, context lengths, and capabilities.
integration__openrouter__openrouter_create_completion openrouter.openrouter_create_completion Write Create a chat completion using any model available on OpenRouter. Supports multi-turn conversations, system prompts, temperature control, and configurable output length.
integration__openrouter__openrouter_list_generations openrouter.openrouter_list_generations Read List generation records from OpenRouter. Returns generation IDs, models used, token counts, and costs.
integration__openrouter__openrouter_get_generation openrouter.openrouter_get_generation Read Get details for a specific OpenRouter generation, including token usage, costs, and latency.
integration__openrouter__openrouter_list_api_keys openrouter.openrouter_list_api_keys Read List API keys for the OpenRouter account. Returns key names, creation dates, and usage limits.
integration__openrouter__openrouter_get_usage openrouter.openrouter_get_usage Read Get usage statistics for the OpenRouter account, including token counts and costs.
integration__openrouter__openrouter_get_current_user openrouter.openrouter_get_current_user Read Get the authenticated user's profile and account information.

Related OpenRouter Pages