KosmoKrator

productivity

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.

OpenRouter CLI Setup

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

Install, configure, and verify
# 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 reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.

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

Command Patterns

The generic command is stable across every integration. The provider shortcut is shorter for humans.

Generic CLI call
kosmo integrations:call openrouter.openrouter_list_models '{}' --json
Provider shortcut
kosmo integrations:openrouter openrouter_list_models '{}' --json

Discovery

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

Discovery commands
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

Automation Contexts

The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.

CLI Functions

Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.

openrouter.openrouter_list_models

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

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_models '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_models '{}' --json

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.

Write write
Parameters
model, messages, max_tokens, temperature, top_p, stop, stream
Generic 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
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_create_response

Create a response through the Responses-compatible endpoint.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_response '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_response '{}' --json

openrouter.openrouter_create_message

Create a message through the messages endpoint.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_message '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_message '{}' --json

openrouter.openrouter_create_embedding

Create embeddings using an OpenRouter embedding model.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_embedding '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_embedding '{}' --json

openrouter.openrouter_list_embedding_models

List models that support embeddings.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_embedding_models '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_embedding_models '{}' --json

openrouter.openrouter_rerank

Rerank documents for a query using OpenRouter reranking models.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_rerank '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_rerank '{}' --json

openrouter.openrouter_list_generations

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

Read read
Parameters
limit, offset, order
Generic call
kosmo integrations:call openrouter.openrouter_list_generations '{"limit":1,"offset":1,"order":"example_order"}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_generations '{"limit":1,"offset":1,"order":"example_order"}' --json

openrouter.openrouter_get_generation

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

Read read
Parameters
id
Generic call
kosmo integrations:call openrouter.openrouter_get_generation '{"id":"example_id"}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_generation '{"id":"example_id"}' --json

openrouter.openrouter_get_generation_content

Get stored prompt and completion content for a generation.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_generation_content '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_generation_content '{}' --json

openrouter.openrouter_count_models

Count available models with optional OpenRouter filters.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_count_models '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_count_models '{}' --json

openrouter.openrouter_list_user_models

List models filtered by the account preferences and guardrails.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_user_models '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_user_models '{}' --json

openrouter.openrouter_list_model_endpoints

List provider endpoints for a specific OpenRouter model.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_model_endpoints '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_model_endpoints '{}' --json

openrouter.openrouter_list_providers

List OpenRouter providers and availability metadata.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_providers '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_providers '{}' --json

openrouter.openrouter_get_credits

Get the account credit balance.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_credits '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_credits '{}' --json

openrouter.openrouter_get_activity

Get account activity with optional filters.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_activity '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_activity '{}' --json

openrouter.openrouter_list_api_keys

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

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_api_keys '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_api_keys '{}' --json

openrouter.openrouter_get_api_key

Get one API key by hash.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_api_key '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_api_key '{}' --json

openrouter.openrouter_create_api_key

Create an API key with OpenRouter key limits and metadata.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_api_key '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_api_key '{}' --json

openrouter.openrouter_update_api_key

Update an OpenRouter API key by hash.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_update_api_key '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_update_api_key '{}' --json

openrouter.openrouter_delete_api_key

Delete an OpenRouter API key by hash.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_delete_api_key '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_delete_api_key '{}' --json

openrouter.openrouter_get_usage

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

Read read
Parameters
period
Generic call
kosmo integrations:call openrouter.openrouter_get_usage '{"period":"example_period"}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_usage '{"period":"example_period"}' --json

openrouter.openrouter_get_current_user

Get the authenticated user's profile and account information.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_current_user '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_current_user '{}' --json

openrouter.openrouter_list_organization_members

List OpenRouter organization members.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_organization_members '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_organization_members '{}' --json

openrouter.openrouter_list_workspaces

List OpenRouter workspaces.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_workspaces '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_workspaces '{}' --json

openrouter.openrouter_get_workspace

Get one OpenRouter workspace.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_workspace '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_workspace '{}' --json

openrouter.openrouter_create_workspace

Create an OpenRouter workspace.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_workspace '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_workspace '{}' --json

openrouter.openrouter_update_workspace

Update an OpenRouter workspace.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_update_workspace '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_update_workspace '{}' --json

openrouter.openrouter_delete_workspace

Delete an OpenRouter workspace.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_delete_workspace '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_delete_workspace '{}' --json

openrouter.openrouter_list_guardrails

List guardrails configured for the account.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_guardrails '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_guardrails '{}' --json

openrouter.openrouter_list_video_models

List models that support video generation.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_list_video_models '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_list_video_models '{}' --json

openrouter.openrouter_create_video

Submit a video generation request.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_create_video '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_create_video '{}' --json

openrouter.openrouter_get_video

Poll video generation job status.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_get_video '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_get_video '{}' --json

openrouter.openrouter_api_get

Call a safe relative OpenRouter GET path for newly released endpoints.

Read read
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_api_get '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_api_get '{}' --json

openrouter.openrouter_api_post

Call a safe relative OpenRouter POST path for newly released endpoints.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_api_post '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_api_post '{}' --json

openrouter.openrouter_api_patch

Call a safe relative OpenRouter PATCH path for newly released endpoints.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_api_patch '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_api_patch '{}' --json

openrouter.openrouter_api_delete

Call a safe relative OpenRouter DELETE path for newly released endpoints.

Write write
Parameters
none
Generic call
kosmo integrations:call openrouter.openrouter_api_delete '{}' --json
Shortcut
kosmo integrations:openrouter openrouter_api_delete '{}' --json

Function Schemas

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

openrouter.openrouter_list_models 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_models --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_completion 7 parameters
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_create_response 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_response --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_message 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_message --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_embedding 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_embedding --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_embedding_models 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_embedding_models --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_rerank 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_rerank --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_generations 3 parameters
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 1 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_generation --json
ParameterTypeRequiredDescription
id string yes The generation identifier.
openrouter.openrouter_get_generation_content 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_generation_content --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_count_models 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_count_models --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_user_models 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_user_models --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_model_endpoints 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_model_endpoints --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_providers 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_providers --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_credits 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_credits --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_activity 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_activity --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_api_keys 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_api_keys --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_api_key 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_api_key --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_api_key 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_api_key --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_update_api_key 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_update_api_key --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_delete_api_key 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_delete_api_key --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_usage 1 parameters
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 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_current_user --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_organization_members 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_organization_members --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_workspaces 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_workspaces --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_workspace 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_workspace --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_workspace 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_workspace --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_update_workspace 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_update_workspace --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_delete_workspace 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_delete_workspace --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_guardrails 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_guardrails --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_list_video_models 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_list_video_models --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_create_video 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_create_video --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_get_video 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_get_video --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_api_get 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_api_get --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_api_post 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_api_post --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_api_patch 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_api_patch --json
ParameterTypeRequiredDescription
No parameters.
openrouter.openrouter_api_delete 0 parameters
Schema command
kosmo integrations:schema openrouter.openrouter_api_delete --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.