Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/openrouter-install-auth

@820dfc8
Run it yourself

Set up OpenRouter API authentication and configure API keys. Use when starting a new OpenRouter integration, rotating keys, or troubleshooting auth issues. Triggers: 'openrouter setup', 'openrouter api key', 'configure openrouter auth', 'sk-or key'.

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/openrouter-install-auth

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈778 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Install & Auth Examples

Environment Setup

# Add to your .env file
OPENROUTER_API_KEY=sk-or-v1-your-key-here

# Or export directly
export OPENROUTER_API_KEY="sk-or-v1-your-key-here"

# Verify the variable is set
echo "Key starts with: ${OPENROUTER_API_KEY:0:8}..."

Python — Initialize Client and Verify Auth

import os
from openai import OpenAI, AuthenticationError

def create_openrouter_client() -> OpenAI:
    """Create and verify an OpenRouter client."""
    api_key = os.environ.get("OPENROUTER_API_KEY")
    if not api_key:
        raise ValueError("OPENROUTER_API_KEY environment variable not set")
    if not api_key.startswith("sk-or-"):
        raise ValueError("Invalid key format — must start with 'sk-or-'")

    return OpenAI(
        base_url="https://openrouter.ai/api/v1",
        api_key=api_key,
        default_headers={
            "HTTP-Referer": "https://your-app.com",
            "X-Title": "Your App Name",
        },
    )

def verify_auth(client: OpenAI) -> bool:
    """Send a minimal request to verify authentication."""
    try:
        response = client.chat.completions.create(
            model="google/gemma-2-9b-it:free",
            messages=[{"role": "user", "content": "Hi"}],
            max_tokens=1,
        )
        print(f"Auth OK — used model: {response.model}")
        return True
    except AuthenticationError as e:
        print(f"Auth failed: {e.message}")
        return False

client = create_openrouter_client()
verify_auth(client)

TypeScript — Initialize Client and Verify Auth

import OpenAI from "openai";

function createClient(): OpenAI {
  const apiKey = process.env.OPENROUTER_API_KEY;
  if (!apiKey) throw new Error("OPENROUTER_API_KEY not set");
  if (!apiKey.startsWith("sk-or-"))
    throw new Error("Invalid key format — must start with 'sk-or-'");

  return new OpenAI({
    baseURL: "https://openrouter.ai/api/v1",
    apiKey,
    defaultHeaders: {
      "HTTP-Referer": "https://your-app.com",
      "X-Title": "Your App Name",
    },
  });
}

async function verifyAuth(client: OpenAI): Promise<boolean> {
  try {
    const res = await client.chat.completions.create({
      model: "google/gemma-2-9b-it:free",
      messages: [{ role: "user", content: "Hi" }],
      max_tokens: 1,
    });
    console.log(`Auth OK — model: ${res.model}`);
    return true;
  } catch (err: any) {
    console.error(`Auth failed: ${err.message}`);
    return false;
  }
}

const client = createClient();
verifyAuth(client);

cURL — Check Key and Credit Balance

# Verify key is valid by checking credits
curl -s https://openrouter.ai/api/v1/auth/key \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq .

# Expected response:
# {
#   "data": {
#     "label": "My App Key",
#     "usage": 0.0023,
#     "limit": 10,
#     "is_free_tier": false,
#     "rate_limit": { "requests": 200, "interval": "10s" }
#   }
# }

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides standard instructions and code examples for setting up OpenRouter API authentication. It follows security best practices by recommending environment variables for secret management and provides links to official documentation and vendor-owned resources.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 820dfc8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files Edits files Runs commands
version
1.20.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "openrouter",
  "api",
  "authentication",
  "setup"
]
All 8 allowed tools
ReadWriteEditGrepBash(python3:*)Bash(node:*)Bash(pip:*)Bash(npm:*)
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/openrouter-install-auth