KosmoKrator

ai

OpenRouter CLI for AI Agents

Use the OpenRouter CLI from KosmoKrator to call OpenRouter tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

7 functions 6 read 1 write API key auth

OpenRouter CLI Setup

OpenRouter can be configured headlessly with `kosmokrator integrations:configure openrouter`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure openrouter --set api_key="$OPENROUTER_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor openrouter --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key OPENROUTER_API_KEY Secret secret yes API Key
url OPENROUTER_URL URL url no API Base URL

Call OpenRouter Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call openrouter.openrouter_list_models '{}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:openrouter openrouter_list_models '{}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs openrouter --json
kosmo integrations:docs openrouter.openrouter_list_models --json
kosmo integrations:schema openrouter.openrouter_list_models --json
kosmo integrations:search "OpenRouter" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to OpenRouter.

openrouter.openrouter_list_models

Read read

List available AI models on OpenRouter. Returns model identifiers, names, pricing, context lengths, and capabilities.

Parameters
none

Generic CLI call

kosmo integrations:call openrouter.openrouter_list_models '{}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_list_models '{}' --json

openrouter.openrouter_create_completion

Write write

Create a chat completion using any model available on OpenRouter. Supports multi-turn conversations, system prompts, temperature control, and configurable output length.

Parameters
model, messages, max_tokens, temperature, top_p, stop, stream

Generic CLI call

kosmo integrations:call openrouter.openrouter_create_completion '{"model":"example_model","messages":"example_messages","max_tokens":1,"temperature":1,"top_p":1,"stop":"example_stop","stream":true}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_create_completion '{"model":"example_model","messages":"example_messages","max_tokens":1,"temperature":1,"top_p":1,"stop":"example_stop","stream":true}' --json

openrouter.openrouter_list_generations

Read read

List generation records from OpenRouter. Returns generation IDs, models used, token counts, and costs.

Parameters
limit, offset, order

Generic CLI call

kosmo integrations:call openrouter.openrouter_list_generations '{"limit":1,"offset":1,"order":"example_order"}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_list_generations '{"limit":1,"offset":1,"order":"example_order"}' --json

openrouter.openrouter_get_generation

Read read

Get details for a specific OpenRouter generation, including token usage, costs, and latency.

Parameters
id

Generic CLI call

kosmo integrations:call openrouter.openrouter_get_generation '{"id":"example_id"}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_get_generation '{"id":"example_id"}' --json

openrouter.openrouter_list_api_keys

Read read

List API keys for the OpenRouter account. Returns key names, creation dates, and usage limits.

Parameters
none

Generic CLI call

kosmo integrations:call openrouter.openrouter_list_api_keys '{}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_list_api_keys '{}' --json

openrouter.openrouter_get_usage

Read read

Get usage statistics for the OpenRouter account, including token counts and costs.

Parameters
period

Generic CLI call

kosmo integrations:call openrouter.openrouter_get_usage '{"period":"example_period"}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_get_usage '{"period":"example_period"}' --json

openrouter.openrouter_get_current_user

Read read

Get the authenticated user's profile and account information.

Parameters
none

Generic CLI call

kosmo integrations:call openrouter.openrouter_get_current_user '{}' --json

Provider shortcut

kosmo integrations:openrouter openrouter_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

openrouter.openrouter_list_models

List available AI models on OpenRouter. Returns model identifiers, names, pricing, context lengths, and capabilities.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_list_models --json
ParameterTypeRequiredDescription
No parameters.

openrouter.openrouter_create_completion

Create a chat completion using any model available on OpenRouter. Supports multi-turn conversations, system prompts, temperature control, and configurable output length.

Operation
Write write
Schema command
kosmo integrations:schema openrouter.openrouter_create_completion --json
ParameterTypeRequiredDescription
model string yes The model to use (e.g., "openai/gpt-4o", "anthropic/claude-3.5-sonnet", "meta-llama/llama-3-70b-instruct").
messages array yes Array of message objects with "role" ("system", "user", or "assistant") and "content" (string).
max_tokens integer no Maximum number of tokens to generate in the response.
temperature number no Controls randomness in generation (0.0–2.0). Lower values are more deterministic.
top_p number no Nucleus sampling parameter (0.0–1.0). Limits cumulative probability of tokens considered.
stop array no Array of strings that will cause the model to stop generating if encountered.
stream boolean no Whether to stream the response incrementally (default: false).

openrouter.openrouter_list_generations

List generation records from OpenRouter. Returns generation IDs, models used, token counts, and costs.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_list_generations --json
ParameterTypeRequiredDescription
limit integer no Maximum number of generations to return per page.
offset integer no Number of generations to skip for pagination.
order string no Sort order — "asc" or "desc" (default: "desc").

openrouter.openrouter_get_generation

Get details for a specific OpenRouter generation, including token usage, costs, and latency.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_get_generation --json
ParameterTypeRequiredDescription
id string yes The generation identifier.

openrouter.openrouter_list_api_keys

List API keys for the OpenRouter account. Returns key names, creation dates, and usage limits.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_list_api_keys --json
ParameterTypeRequiredDescription
No parameters.

openrouter.openrouter_get_usage

Get usage statistics for the OpenRouter account, including token counts and costs.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_get_usage --json
ParameterTypeRequiredDescription
period string no Time period for usage data (e.g., "day", "week", "month").

openrouter.openrouter_get_current_user

Get the authenticated user's profile and account information.

Operation
Read read
Schema command
kosmo integrations:schema openrouter.openrouter_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.