OP

openrouter-hello-world

Verifies your OpenRouter API connectivity by sending a basic request and parsing the response.

Install

mkdir -p .claude/skills/openrouter-hello-world && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1606" && unzip -o skill.zip -d .claude/skills/openrouter-hello-world && rm skill.zip

Installs to .claude/skills/openrouter-hello-world

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Send your first OpenRouter API request and understand the response.
67 charsno explicit “when” trigger
Beginner

Key capabilities

  • Send a chat completion request to OpenRouter
  • Understand the structure of the API response
  • Switch between different LLM models
  • Query generation stats for cost tracking
  • Handle common API errors like invalid keys or models

How it works

The skill sends a chat completion request to the OpenRouter API endpoint, which processes the request and returns a structured JSON response.

Inputs & outputs

You give it
A cURL command or Python/TypeScript code with an API key and a chat completion request payload
You get back
A JSON response containing the model's reply, request ID, model used, and token usage

When to use openrouter-hello-world

  • Verify OpenRouter API access
  • Test chat completion request
  • Switch between LLM models
  • Understand API response structure

About this skill

OpenRouter Hello World

Overview

Send a minimal chat completion request through OpenRouter, understand the response format, try different models, and verify the full round-trip works. All requests go to the single endpoint POST https://openrouter.ai/api/v1/chat/completions.

Prerequisites

  • An OpenRouter API key (sk-or-v1-...) exported as OPENROUTER_API_KEY — see the openrouter-install-auth skill for setup
  • curl and jq for the command-line request, or Python 3.8+ / Node.js 18+ with the OpenAI SDK (pip install openai / npm install openai)
  • A free-tier model works for every step here (no credits required for :free models)

Instructions

  1. Export your key: export OPENROUTER_API_KEY="sk-or-v1-...".
  2. Send the minimal cURL request below and confirm you get a choices[0].message.content back.
  3. Read the Response Format section to identify the four key fields (id, model, usage, finish_reason).
  4. Repeat the same request from your app language using the Python or TypeScript example.
  5. Swap model IDs per Try Different Models to confirm multi-model access works with the same code.
  6. Query GET /api/v1/generation?id=gen-... per Check Generation Cost to verify cost tracking on the request you just sent.

Minimal Request (cURL)

curl -s https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemma-2-9b-it:free",
    "messages": [{"role": "user", "content": "Say hello in three languages"}],
    "max_tokens": 100
  }' | jq .

Response Format

{
  "id": "gen-abc123xyz",
  "model": "google/gemma-2-9b-it:free",
  "object": "chat.completion",
  "created": 1711234567,
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! Bonjour! Hola!"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 8,
    "total_tokens": 20
  }
}

Key fields:

  • id (gen-...) -- use this to query generation stats via GET /api/v1/generation?id=gen-abc123xyz
  • model -- confirms which model actually served the request
  • usage -- token counts for cost calculation
  • finish_reason -- stop (complete), length (hit max_tokens), tool_calls (function call)

Python Example

from openai import OpenAI
import os

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
    default_headers={"HTTP-Referer": "https://your-app.com", "X-Title": "My App"},
)

# Basic completion
response = client.chat.completions.create(
    model="google/gemma-2-9b-it:free",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is OpenRouter in one sentence?"},
    ],
    max_tokens=100,
)

print(response.choices[0].message.content)
print(f"Model: {response.model}")
print(f"Tokens: {response.usage.prompt_tokens} prompt + {response.usage.completion_tokens} completion")

TypeScript Example

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
  defaultHeaders: { "HTTP-Referer": "https://your-app.com", "X-Title": "My App" },
});

const res = await client.chat.completions.create({
  model: "google/gemma-2-9b-it:free",
  messages: [{ role: "user", content: "What is OpenRouter in one sentence?" }],
  max_tokens: 100,
});

console.log(res.choices[0].message.content);
console.log(`Model: ${res.model} | Tokens: ${res.usage?.total_tokens}`);

Try Different Models

# Swap model ID to access any of 400+ models
models_to_try = [
    "google/gemma-2-9b-it:free",         # Free tier
    "meta-llama/llama-3.1-8b-instruct",  # Open-source
    "anthropic/claude-3.5-sonnet",        # Anthropic
    "openai/gpt-4o",                      # OpenAI
    "openrouter/auto",                    # Auto-router (picks best model)
]

for model_id in models_to_try:
    try:
        r = client.chat.completions.create(
            model=model_id,
            messages=[{"role": "user", "content": "Hi"}],
            max_tokens=10,
        )
        print(f"{model_id}: {r.choices[0].message.content}")
    except Exception as e:
        print(f"{model_id}: {e}")

Check Generation Cost

# After a request, query the generation endpoint for cost details
curl -s "https://openrouter.ai/api/v1/generation?id=gen-abc123xyz" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq '{
    model: .data.model,
    tokens_prompt: .data.tokens_prompt,
    tokens_completion: .data.tokens_completion,
    total_cost: .data.total_cost
  }'

Output

A successful round-trip produces:

  • A chat completion JSON with choices[0].message.content holding the model's reply, a gen-... request id, the model that actually served the request, and usage token counts
  • Console output from the Python/TypeScript examples: the reply text plus model name and prompt/completion token counts
  • A cost record from the generation endpoint: tokens_prompt, tokens_completion, and total_cost for the request

Examples

End-to-end run with the minimal cURL request:

$ curl -s https://openrouter.ai/api/v1/chat/completions ... | jq .choices[0].message.content
"Hello! Bonjour! Hola!"

The Python and TypeScript sections above are the same request in SDK form; expected console output:

OpenRouter is a unified API gateway that routes requests to 400+ LLMs.
Model: google/gemma-2-9b-it:free
Tokens: 21 prompt + 17 completion

More worked examples (cURL with full expected response, SDK variants): references/examples.md.

Error Handling

HTTPCauseFix
401Invalid or missing API keyVerify sk-or-v1-... key is exported
402Insufficient credits for paid modelAdd credits or use a :free model
404Wrong base URL or invalid model IDUse https://openrouter.ai/api/v1; check model ID at /api/v1/models
400Malformed JSON or missing messagesEnsure messages array has objects with role and content

Enterprise Considerations

  • Always set max_tokens to prevent unbounded completions
  • Use HTTP-Referer and X-Title headers for usage attribution in dashboards
  • Query /api/v1/generation?id= for async cost auditing
  • Test with free models first, then switch to paid models for production

References

Prerequisites

An OpenRouter API keycurljqPython 3.8+ with OpenAI SDK (optional for Python example)

Limitations

  • Requires an OpenRouter API key
  • Requires `curl` and `jq` for command-line requests
  • Requires Python 3.8+ or Node.js 18+ with OpenAI SDK for language-specific examples

How it compares

This skill provides specific code examples for OpenRouter's API, unlike a generic HTTP request that would require manual construction of the payload and parsing of the response.

Compared to similar skills

openrouter-hello-world side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
openrouter-hello-world (this skill)727dCautionBeginner
telegram-dev28moReviewIntermediate
langfuse-install-auth027dReviewBeginner
perplexity-known-pitfalls027dReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

telegram-dev

2025Emma

Telegram 生态开发全栈指南 - 涵盖 Bot API、Mini Apps (Web Apps)、MTProto 客户端开发。包括消息处理、支付、内联模式、Webhook、认证、存储、传感器 API 等完整开发资源。

232

langfuse-install-auth

jeremylongshore

Install and configure Langfuse SDK authentication for LLM observability. Use when setting up a new Langfuse integration, configuring API keys, or initializing Langfuse tracing in your project. Trigger with phrases like "install langfuse", "setup langfuse", "langfuse auth", "configure langfuse API key", "langfuse tracing setup".

01

perplexity-known-pitfalls

jeremylongshore

Identify and avoid Perplexity anti-patterns and common integration mistakes. Use when reviewing Perplexity code for issues, onboarding new developers, or auditing existing Perplexity integrations for best practices violations. Trigger with phrases like "perplexity mistakes", "perplexity anti-patterns", "perplexity pitfalls", "perplexity what not to do", "perplexity code review".

01

perplexity-upgrade-migration

jeremylongshore

Analyze, plan, and execute Perplexity SDK upgrades with breaking change detection. Use when upgrading Perplexity SDK versions, detecting deprecations, or migrating to new API versions. Trigger with phrases like "upgrade perplexity", "perplexity migration", "perplexity breaking changes", "update perplexity SDK", "analyze perplexity version".

10

context7-efficient

diegosouzapw

Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, nee

00

ast-grep-find

parcadei

AST-based code search and refactoring via ast-grep MCP

325

Search skills

Search the agent skills registry