ai
OpenRouter CLI for Coding Agents
Use the OpenRouter CLI for coding agents with headless JSON commands, schema discovery, credentials, and permission controls.
7 functions 6 read 1 write API key auth
OpenRouter CLI for Coding Agents
Let coding agents discover schemas and execute integration functions through CLI commands or MCP.
Use this pattern when another coding agent needs exact commands and schema discovery. The OpenRouter CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# OpenRouter CLI for Coding Agents
kosmokrator integrations:configure openrouter --set api_key="$OPENROUTER_API_KEY" --enable --read allow --write ask --json
kosmo integrations:call openrouter.openrouter_list_models '{}' --json Discovery Before Execution
Agents and scripts can inspect OpenRouter docs and schemas 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 Useful OpenRouter CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
openrouter.openrouter_list_models | Read | none | List available AI models on OpenRouter. Returns model identifiers, names, pricing, context lengths, and capabilities. |
openrouter.openrouter_create_completion | Write | model, messages, max_tokens, temperature, top_p, stop, stream | Create a chat completion using any model available on OpenRouter. Supports multi-turn conversations, system prompts, temperature control, and configurable output length. |
openrouter.openrouter_list_generations | Read | limit, offset, order | List generation records from OpenRouter. Returns generation IDs, models used, token counts, and costs. |
openrouter.openrouter_get_generation | Read | id | Get details for a specific OpenRouter generation, including token usage, costs, and latency. |
openrouter.openrouter_list_api_keys | Read | none | List API keys for the OpenRouter account. Returns key names, creation dates, and usage limits. |
openrouter.openrouter_get_usage | Read | period | Get usage statistics for the OpenRouter account, including token counts and costs. |
openrouter.openrouter_get_current_user | Read | none | Get the authenticated user's profile and account information. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.