| name | openrouter-hello-world |
| description | Send your first OpenRouter API request and understand the response. Use when learning OpenRouter, testing setup, or verifying connectivity. Triggers: 'openrouter hello world', 'openrouter first request', 'test openrouter', 'openrouter quickstart'.
|
| allowed-tools | Read, Write, Edit, Grep, Bash(curl:*), Bash(python3:*), Bash(node:*), Bash(jq:*) |
| version | 1.20.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","openrouter","api","quickstart"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
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
- Export your key:
export OPENROUTER_API_KEY="sk-or-v1-...".
- Send the minimal cURL request below and confirm you get a
choices[0].message.content back.
- Read the Response Format section to identify the four key fields (
id, model, usage, finish_reason).
- Repeat the same request from your app language using the Python or TypeScript example.
- Swap model IDs per Try Different Models to confirm multi-model access works with the same code.
- 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"