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 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.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
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.
kosmo integrations:call openrouter.openrouter_list_models '{}' --json 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.
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 - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_models '{}' --json 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 - Parameters
- model, messages, max_tokens, temperature, top_p, stop, stream
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 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 - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_response '{}' --json kosmo integrations:openrouter openrouter_create_response '{}' --json openrouter.openrouter_create_message
Create a message through the messages endpoint.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_message '{}' --json kosmo integrations:openrouter openrouter_create_message '{}' --json openrouter.openrouter_create_embedding
Create embeddings using an OpenRouter embedding model.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_embedding '{}' --json kosmo integrations:openrouter openrouter_create_embedding '{}' --json openrouter.openrouter_list_embedding_models
List models that support embeddings.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_embedding_models '{}' --json kosmo integrations:openrouter openrouter_list_embedding_models '{}' --json openrouter.openrouter_rerank
Rerank documents for a query using OpenRouter reranking models.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_rerank '{}' --json 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 - Parameters
- limit, offset, order
kosmo integrations:call openrouter.openrouter_list_generations '{"limit":1,"offset":1,"order":"example_order"}' --json 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 - Parameters
- id
kosmo integrations:call openrouter.openrouter_get_generation '{"id":"example_id"}' --json 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 - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_generation_content '{}' --json kosmo integrations:openrouter openrouter_get_generation_content '{}' --json openrouter.openrouter_count_models
Count available models with optional OpenRouter filters.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_count_models '{}' --json kosmo integrations:openrouter openrouter_count_models '{}' --json openrouter.openrouter_list_user_models
List models filtered by the account preferences and guardrails.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_user_models '{}' --json kosmo integrations:openrouter openrouter_list_user_models '{}' --json openrouter.openrouter_list_model_endpoints
List provider endpoints for a specific OpenRouter model.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_model_endpoints '{}' --json kosmo integrations:openrouter openrouter_list_model_endpoints '{}' --json openrouter.openrouter_list_providers
List OpenRouter providers and availability metadata.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_providers '{}' --json kosmo integrations:openrouter openrouter_list_providers '{}' --json openrouter.openrouter_get_credits
Get the account credit balance.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_credits '{}' --json kosmo integrations:openrouter openrouter_get_credits '{}' --json openrouter.openrouter_get_activity
Get account activity with optional filters.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_activity '{}' --json 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 - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_api_keys '{}' --json kosmo integrations:openrouter openrouter_list_api_keys '{}' --json openrouter.openrouter_get_api_key
Get one API key by hash.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_api_key '{}' --json kosmo integrations:openrouter openrouter_get_api_key '{}' --json openrouter.openrouter_create_api_key
Create an API key with OpenRouter key limits and metadata.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_api_key '{}' --json kosmo integrations:openrouter openrouter_create_api_key '{}' --json openrouter.openrouter_update_api_key
Update an OpenRouter API key by hash.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_update_api_key '{}' --json kosmo integrations:openrouter openrouter_update_api_key '{}' --json openrouter.openrouter_delete_api_key
Delete an OpenRouter API key by hash.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_delete_api_key '{}' --json 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 - Parameters
- period
kosmo integrations:call openrouter.openrouter_get_usage '{"period":"example_period"}' --json 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 - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_current_user '{}' --json kosmo integrations:openrouter openrouter_get_current_user '{}' --json openrouter.openrouter_list_organization_members
List OpenRouter organization members.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_organization_members '{}' --json kosmo integrations:openrouter openrouter_list_organization_members '{}' --json openrouter.openrouter_list_workspaces
List OpenRouter workspaces.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_workspaces '{}' --json kosmo integrations:openrouter openrouter_list_workspaces '{}' --json openrouter.openrouter_get_workspace
Get one OpenRouter workspace.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_workspace '{}' --json kosmo integrations:openrouter openrouter_get_workspace '{}' --json openrouter.openrouter_create_workspace
Create an OpenRouter workspace.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_workspace '{}' --json kosmo integrations:openrouter openrouter_create_workspace '{}' --json openrouter.openrouter_update_workspace
Update an OpenRouter workspace.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_update_workspace '{}' --json kosmo integrations:openrouter openrouter_update_workspace '{}' --json openrouter.openrouter_delete_workspace
Delete an OpenRouter workspace.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_delete_workspace '{}' --json kosmo integrations:openrouter openrouter_delete_workspace '{}' --json openrouter.openrouter_list_guardrails
List guardrails configured for the account.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_guardrails '{}' --json kosmo integrations:openrouter openrouter_list_guardrails '{}' --json openrouter.openrouter_list_video_models
List models that support video generation.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_list_video_models '{}' --json kosmo integrations:openrouter openrouter_list_video_models '{}' --json openrouter.openrouter_create_video
Submit a video generation request.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_create_video '{}' --json kosmo integrations:openrouter openrouter_create_video '{}' --json openrouter.openrouter_get_video
Poll video generation job status.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_get_video '{}' --json kosmo integrations:openrouter openrouter_get_video '{}' --json openrouter.openrouter_api_get
Call a safe relative OpenRouter GET path for newly released endpoints.
read - Parameters
- none
kosmo integrations:call openrouter.openrouter_api_get '{}' --json kosmo integrations:openrouter openrouter_api_get '{}' --json openrouter.openrouter_api_post
Call a safe relative OpenRouter POST path for newly released endpoints.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_api_post '{}' --json kosmo integrations:openrouter openrouter_api_post '{}' --json openrouter.openrouter_api_patch
Call a safe relative OpenRouter PATCH path for newly released endpoints.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_api_patch '{}' --json kosmo integrations:openrouter openrouter_api_patch '{}' --json openrouter.openrouter_api_delete
Call a safe relative OpenRouter DELETE path for newly released endpoints.
write - Parameters
- none
kosmo integrations:call openrouter.openrouter_api_delete '{}' --json 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
kosmo integrations:schema openrouter.openrouter_list_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_completion 7 parameters
kosmo integrations:schema openrouter.openrouter_create_completion --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema openrouter.openrouter_create_response --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_message 0 parameters
kosmo integrations:schema openrouter.openrouter_create_message --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_embedding 0 parameters
kosmo integrations:schema openrouter.openrouter_create_embedding --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_embedding_models 0 parameters
kosmo integrations:schema openrouter.openrouter_list_embedding_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_rerank 0 parameters
kosmo integrations:schema openrouter.openrouter_rerank --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_generations 3 parameters
kosmo integrations:schema openrouter.openrouter_list_generations --json | Parameter | Type | Required | Description |
|---|---|---|---|
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
kosmo integrations:schema openrouter.openrouter_get_generation --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The generation identifier. |
openrouter.openrouter_get_generation_content 0 parameters
kosmo integrations:schema openrouter.openrouter_get_generation_content --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_count_models 0 parameters
kosmo integrations:schema openrouter.openrouter_count_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_user_models 0 parameters
kosmo integrations:schema openrouter.openrouter_list_user_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_model_endpoints 0 parameters
kosmo integrations:schema openrouter.openrouter_list_model_endpoints --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_providers 0 parameters
kosmo integrations:schema openrouter.openrouter_list_providers --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_credits 0 parameters
kosmo integrations:schema openrouter.openrouter_get_credits --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_activity 0 parameters
kosmo integrations:schema openrouter.openrouter_get_activity --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_api_keys 0 parameters
kosmo integrations:schema openrouter.openrouter_list_api_keys --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_api_key 0 parameters
kosmo integrations:schema openrouter.openrouter_get_api_key --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_api_key 0 parameters
kosmo integrations:schema openrouter.openrouter_create_api_key --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_update_api_key 0 parameters
kosmo integrations:schema openrouter.openrouter_update_api_key --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_delete_api_key 0 parameters
kosmo integrations:schema openrouter.openrouter_delete_api_key --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_usage 1 parameters
kosmo integrations:schema openrouter.openrouter_get_usage --json | Parameter | Type | Required | Description |
|---|---|---|---|
period | string | no | Time period for usage data (e.g., "day", "week", "month"). |
openrouter.openrouter_get_current_user 0 parameters
kosmo integrations:schema openrouter.openrouter_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_organization_members 0 parameters
kosmo integrations:schema openrouter.openrouter_list_organization_members --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_workspaces 0 parameters
kosmo integrations:schema openrouter.openrouter_list_workspaces --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_workspace 0 parameters
kosmo integrations:schema openrouter.openrouter_get_workspace --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_workspace 0 parameters
kosmo integrations:schema openrouter.openrouter_create_workspace --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_update_workspace 0 parameters
kosmo integrations:schema openrouter.openrouter_update_workspace --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_delete_workspace 0 parameters
kosmo integrations:schema openrouter.openrouter_delete_workspace --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_guardrails 0 parameters
kosmo integrations:schema openrouter.openrouter_list_guardrails --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_list_video_models 0 parameters
kosmo integrations:schema openrouter.openrouter_list_video_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_create_video 0 parameters
kosmo integrations:schema openrouter.openrouter_create_video --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_get_video 0 parameters
kosmo integrations:schema openrouter.openrouter_get_video --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_api_get 0 parameters
kosmo integrations:schema openrouter.openrouter_api_get --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_api_post 0 parameters
kosmo integrations:schema openrouter.openrouter_api_post --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_api_patch 0 parameters
kosmo integrations:schema openrouter.openrouter_api_patch --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
openrouter.openrouter_api_delete 0 parameters
kosmo integrations:schema openrouter.openrouter_api_delete --json | Parameter | Type | Required | Description |
|---|---|---|---|
| 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.