openrouter-chat

Orchestrate OpenRouter chat completions via Python client and CLI.

27|9|Updated Jan 25, 2026
One-click install
npx skills add https://github.com/Leoyishou/personal-ai-company --skill openrouter-chat
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openrouter-chat
Source: https://github.com/Leoyishou/personal-ai-company/tree/main/claude-global/skills/api-openrouter
Command: npx skills add https://github.com/Leoyishou/personal-ai-company --skill openrouter-chat

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests, python-dotenv, and includes scripts (resource) components.

What problem does it solve?

This skill enables local orchestration of OpenRouter chat completions via a Python client, simplifying multi-model calls and integration in Claude Code workflows.

Core Features & Use Cases

  • Single-turn and multi-turn message support
  • System prompts and optional extra payloads
  • Returns both content and raw JSON for debugging and logging
  • Works with local scripts for quick automation

Quick Start

Run the CLI example to call the OpenRouter chat endpoint and print the response.

Frequently Asked Questions about openrouter-chat

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call OpenRouter chat models from a Python CLI script?

You can call OpenRouter chat models locally by using a Python client and CLI bindings that build HTTP requests with your model, temperature, and message history, returning the generated content directly.

Can I maintain multi-turn message histories when sending prompts to OpenRouter?

Yes, multi-turn message histories are fully supported. The client validates your message array and sends the complete conversation context to the OpenRouter API to maintain dialogue continuity.

Does this OpenRouter Python client support system prompts and structured outputs?

Yes, the client supports configuring system prompts and optional structured outputs. It also accepts extra payloads like max_tokens and returns both content and raw JSON for debugging.

Do I need the requests and python-dotenv packages to run this OpenRouter CLI?

Yes, you need the requests and python-dotenv packages installed. The client uses requests for HTTP calls and python-dotenv to load your OpenRouter API key from local environment variables.

Why does my OpenRouter API call return raw JSON instead of just the text content?

The client returns both the parsed content and the raw JSON response to assist with debugging and logging. You can extract the specific text field from the raw JSON if you need the raw API payload.

What is the best way to handle API errors when automating OpenRouter chat completions?

The client handles API errors internally during the HTTP request process. It validates messages before sending and manages error responses, returning both content and raw JSON to help you log issues.