Communitygithub.com

ASoudy/AGS

OpenRouter API - 하나의 API로 400개 이상의 AI 모델에 통합 접근

AGS란 무엇인가요?

이 스킬은 OpenRouter API를 개발하고 사용하는 데 필요한 포괄적인 지원을 제공합니다. OpenRouter는 단일 엔드포인트를 통해 수백 개의 AI 모델에 대한 통합된 액세스를 제공하며, 지능형 라우팅, 자동 폴백(fallback), 표준화된 인터페이스를 갖추고 있습니다. 개발자는 OpenAI 호환 SDK, cURL 등 익숙한 도구를 사용하여 다양한 제공업체의 모델에 쉽게 접근하고, 모델 간 장애 조치(failover) 전략을 구현하며, 세분화된 샘플링 매개변수(온도, top_p, 페널티)를 구성할 수 있습니다. 이 스킬은 Python, TypeScript, cURL에 대한 실제 코드 예제를 제공하며, 모델 라우팅, JSON 모드, 스트리밍, 시드(seed) 기반 결정론적 출력과 같은 고급 기능을 다룹니다. 초보자부터 고급 사용자까지 단계별 가이드와 함께 모델 명명 규칙, 키 개념, 일반적인 패턴이 포함되어 있어 생산 준비가 완료된 AI 애플리케이션을 구축하는 데 필수적인 도구입니다.

지원 대상✓Claude Code✓Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/ASoudy/AGS/tree/HEAD/claude_skills_libraries/landing-page-mastery/skills/openrouter

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

OpenRouter 스킬

OpenRouter API 개발에 대한 포괄적인 지원을 제공합니다. 단일 엔드포인트를 통해 수백 개의 AI 모델에 지능형 라우팅, 자동 폴백, 표준화된 인터페이스를 제공합니다.

이 스킬을 사용해야 할 때

다음과 같은 경우 이 스킬을 사용해야 합니다:

  • 통합 인터페이스를 통해 여러 AI 모델 제공업체에 API 호출을 할 때
  • 모델 폴백 전략 또는 자동 라우팅을 구현할 때
  • OpenAI 호환 SDK를 사용하면서 여러 제공업체를 대상으로 할 때
  • 고급 샘플링 매개변수(온도, top_p, 페널티)를 구성할 때
  • 스트리밍 응답 또는 구조화된 JSON 출력을 설정할 때
  • 여러 AI 모델 간의 비용을 비교할 때
  • 자동 제공업체 장애 조치가 필요한 애플리케이션을 구축할 때
  • 여러 모델에서 함수/도구 호출을 구현할 때
  • OpenRouter 특정 기능(라우팅, 폴백, 제로 완료 보험)에 대한 질문

빠른 참조

기본 채팅 완료 (Python)

from openai import OpenAI

client = OpenAI(
  base_url="https://openrouter.ai/api/v1",
  api_key="<OPENROUTER_API_KEY>",
)

completion = client.chat.completions.create(
  model="openai/gpt-4o",
  messages=[{"role": "user", "content": "인생의 의미는 무엇인가?"}]
)
print(completion.choices[0].message.content)

기본 채팅 완료 (JavaScript/TypeScript)

import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'https://openrouter.ai/api/v1',
  apiKey: '<OPENROUTER_API_KEY>',
});

const completion = await openai.chat.completions.create({
  model: 'openai/gpt-4o',
  messages: [{"role": 'user', "content": '인생의 의미는 무엇인가?'}],
});
console.log(completion.choices[0].message);

cURL 요청

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "인생의 의미는 무엇인가?"}]
  }'

모델 폴백 구성 (Python)

completion = client.chat.completions.create(
    model="openai/gpt-4o",
    extra_body={
        "models": ["anthropic/claude-3.5-sonnet", "gryphe/mythomax-l2-13b"],
    },
    messages=[{"role": "user", "content": "여기에 프롬프트를 입력하세요"}]
)

모델 폴백 구성 (TypeScript)

const completion = await client.chat.completions.create({
    model: 'openai/gpt-4o',
    models: ['anthropic/claude-3.5-sonnet', 'gryphe/mythomax-l2-13b'],
    messages: [{ role: 'user', content: '여기에 프롬프트를 입력하세요' }],
});

자동 라우터 (동적 모델 선택)

completion = client.chat.completions.create(
    model="openrouter/auto",  # 프롬프트에 가장 적합한 모델을 자동으로 선택
    messages=[{"role": "user", "content": "여기에 프롬프트를 입력하세요"}]
)

고급 매개변수 예제

completion = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "창의적인 이야기를 써줘"}],
    temperature=0.8,           # 창의성을 위해 높게 설정 (0.0-2.0)
    max_tokens=500,            # 응답 길이 제한
    top_p=0.9,                 # 핵심 샘플링 (0.0-1.0)
    frequency_penalty=0.5,     # 반복 감소 (-2.0-2.0)
    presence_penalty=0.3       # 주제 다양성 장려 (-2.0-2.0)
)

스트리밍 응답

stream = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "이야기 하나 해줘"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end='')

JSON 모드 (구조화된 출력)

completion = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{
        "role": "user",
        "content": "다음 문장에서 사람의 이름, 나이, 거주 도시를 추출하세요: John은 30세이고 NYC에 살고 있습니다"
    }],
    response_format={"type": "json_object"}
)

시드(seed)를 사용한 결정론적 출력

completion = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "임의의 숫자를 생성하세요"}],
    seed=42,            # 동일한 시드 = 동일한 출력 (지원되는 경우)
    temperature=0.0     # 결정론적 샘플링
)

주요 개념

모델 라우팅

OpenRouter는 지능형 라우팅 기능을 제공합니다:

  • 자동 라우터 (openrouter/auto): NotDiamond을 사용하여 프롬프트에 가장 적합한 모델을 자동으로 선택
  • 폴백 모델: 기본 모델이 실패하면 자동으로 재시도할 여러 모델 지정
  • 제공업체 라우팅: 안정성을 위해 여러 제공업체에 자동으로 라우팅

인증

  • API 키를 사용한 Bearer 토큰 인증 사용
  • API 키는 프로그래밍 방식으로 관리 가능
  • OpenAI SDK 인증 패턴과 호환

모델 명명 규칙

모델은 provider/model-name 형식을 사용합니다:

  • openai/gpt-4o - OpenAI GPT-4 Optimized
  • anthropic/claude-3.5-sonnet - Anthropic Claude 3.5 Sonnet
  • google/gemini-2.0-flash-exp:free - Google의 무료 Gemini 모델
  • openrouter/auto - 자동 라우팅 시스템

샘플링 매개변수

Temperature (0.0-2.0, 기본값: 1.0)

  • 낮을수록 더 예측 가능하고 집중된 응답
  • 높을수록 더 창의적이고 다양한 응답
  • 사실적 작업에는 낮음(0.0-0.3), 창의적 작업에는 높음(0.8-1.5) 사용

Top P (0.0-1.0, 기본값: 1.0)

  • 가능성이 높은 토큰의 비율로 선택지 제한
  • 가능성이 낮은 옵션 동적 필터링
  • 일관성과 다양성 간의 균형

빈도/존재 페널티 (-2.0-2.0, 기본값: 0.0)

  • 빈도: 사용 비율에 비례하여 토큰 반복 억제
  • 존재: 사용 횟수로 조정되지 않는 단순한 페널티
  • 양수 값은 반복을 줄이고, 음수 값은 재사용을 장려

Max Tokens (정수)

  • 최대 응답 길이 설정
  • 컨텍스트 길이에서 프롬프트 길이를 뺀 값을 초과할 수 없음
  • 비용을 제어하고 간결한 응답을 강제하는 데 사용

응답 형식

  • 표준 JSON: 기본 채팅 완료 형식
  • 스트리밍: stream: true를 사용한 서버 전송 이벤트 (SSE)
  • JSON 모드: response_format: {"type": "json_object"}로 유효한 JSON 보장
  • 구조화된 출력: 스키마 검증된 JSON 응답

고급 기능

  • 도구/함수 호출: 모델을 외부 API에 연결
  • 멀티모달 입력: 이미지, PDF, 오디오 지원
  • 프롬프트 캐싱: 반복되는 프롬프트의 비용 절감
  • 웹 검색 통합: 웹 데이터로 향상된 응답
  • 제로 완료 보험: 실패한 응답에 대한 보호
  • Logprobs: 신뢰도 분석을 위한 토큰 확률 액세스

참조 파일

이 스킬은 references/에 포괄적인 문서를 포함합니다:

  • llms-full.md - 메타데이터가 포함된 사용 가능한 모델의 전체 목록
  • llms-small.md - 인기 있는 모델의 선별된 하위 집합
  • llms.md - 표준 모델 목록

자세한 모델 정보가 필요하면 view를 사용하여 특정 참조 파일을 읽으세요.

이 스킬 사용하기

초보자용

  1. 기본 채팅 완료 예제로 시작하세요 (위의 Python/JavaScript/cURL)
  2. 쉬운 통합을 위해 표준 OpenAI SDK를 사용하세요
  3. openai/gpt-4o 또는 anthropic/claude-3.5-sonnet과 같은 간단한 모델 이름을 시도해보세요
  4. 처음에는 매개변수를 간단하게 (모델과 메시지만) 유지하세요

중급 사용자용

  1. 안정성을 위해 모델 폴백 배열을 구현하세요
  2. 샘플링 매개변수(온도, top_p)를 실험해보세요
  3. 대화형 앱에서 더 나은 사용자 경험을 위해 스트리밍을 사용하세요
  4. 자동 모델 선택을 위해 openrouter/auto를 시도해보세요
  5. 구조화된 데이터 추출을 위해 JSON 모드를 구현하세요

고급 사용자용

  1. 여러 샘플링 매개변수를 함께 미세 조정하세요
  2. 폴백 체인을 사용한 사용자 정의 라우팅 로직을 구현하세요
  3. 신뢰도 점수 매기기에 logprobs를 사용하세요
  4. 도구/함수 호출 기능을 활용하세요
  5. 작업별로 적절한 모델을 선택하여 비용을 최적화하세요
  6. 프롬프트 캐싱 전략을 구현하세요
  7. 재현 가능한 테스트를 위해 시드 매개변수를 사용하세요

일반적인 패턴

폴백을 사용한 오류 처리

try:
    completion = client.chat.completions.create(
        model="openai/gpt-4o",
        extra_body={
            "models": [
                "anthropic/claude-3.5-sonnet",
                "google/gemini-2.0-flash-exp:free"
            ]
        },
        messages=[{"role": "user", "content": "여기에 프롬프트"}]
    )
except Exception as e:
    print(f"모든 모델 실패: {e}")

비용 최적화 라우팅

# 간단한 작업에는 저렴한 모델 사용
simple_completion = client.chat.completions.create(
    model="google/gemini-2.0-flash-exp:free",
    messages=[{"role": "user", "content": "간단한 질문"}]
)

# 복잡한 작업에는 프리미엄 모델 사용
complex_completion = client.chat.completions.create(
    model="openai/o1",
    messages=[{"role": "user", "content": "복잡한 추론 작업"}]
)

컨텍스트 인식 온도 설정

# 사실적 응답에는 낮은 온도
factual = client.chat.completions.create(
    model="openai/gpt-4o",
    temperature=0.2,
    messages=[{"role": "user", "content": "프랑스의 수도는 어디인가요?"}]
)

# 창의적 콘텐츠에는 높은 온도
creative = client.chat.completions.create(
    model="openai/gpt-4o",
    temperature=1.2,
    messages=[{"role": "user", "content": "독특한 이야기 시작 부분을 작성해주세요"}]
)

리소스

공식 문서

주요 엔드포인트

  • 채팅 완료: POST https://openrouter.ai/api/v1/chat/completions
  • 모델 목록: GET https://openrouter.ai/api/v1/models
  • 생성 정보: GET https://openrouter.ai/api/v1/generation

참고 사항

  • OpenRouter는 모든 제공업체의 API 스키마를 정규화합니다
  • 쉬운 마이그레이션을 위해 OpenAI 호환 API 형식을 사용합니다
  • 모델이 속도 제한 또는 다운된 경우 자동 제공업체 폴백
  • 가격은 사용된 실제 모델을 기준으로 합니다 (폴백에 중요)
  • 응답에는 요청을 처리한 모델에 대한 메타데이터가 포함됩니다
  • 모든 모델은 서버 전송 이벤트를 통한 스트리밍을 지원합니다
  • 인기 있는 프레임워크(LangChain, Vercel AI SDK 등)와 호환됩니다

모범 사례

  1. 프로덕션 애플리케이션에는 항상 폴백을 구현하세요
  2. 작업 유형에 따라 적절한 온도를 사용하세요 (사실적 작업에는 낮음, 창의적 작업에는 높음)
  3. max_tokens를 설정하여 비용과 응답 길이를 제어하세요
  4. 채팅 애플리케이션에서 더 나은 사용자 경험을 위해 스트리밍을 활성화하세요
  5. 보장된 구조화된 출력이 필요할 때 JSON 모드를 사용하세요
  6. 개발 중 재현 가능한 결과를 위해 시드 매개변수로 테스트하세요
  7. 작업별로 적절한 모델을 선택하여 비용을 모니터링하세요
  8. 어떤 모델이 가장 잘 수행되는지 확실하지 않을 때 자동 라우팅을 사용하세요
  9. 속도 제한 및 실패에 대한 적절한 오류 처리를 구현하세요
  10. 반복 요청 시 비용 절감을 위해 프롬프트를 캐싱하세요

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ASoudy/AGS

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

ASoudy/AGS

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

ASoudy/AGS

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

ASoudy/AGS

One sentence - what this skill does and when to invoke it

ASoudy/AGS

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

ASoudy/AGS

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

ASoudy/AGS

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

ASoudy/AGS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

ASoudy/AGS

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

ASoudy/AGS

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

ASoudy/AGS

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

ASoudy/AGS

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

ASoudy/AGS

Next.js App Router principles. Server Components, data fetching, routing patterns.

ASoudy/AGS

Expert integration of Supabase Auth with Next.js App Router

ASoudy/AGS

React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

ASoudy/AGS

Best practices for Remotion - Video creation in React

ASoudy/AGS

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

ASoudy/AGS

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

ASoudy/AGS

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

ASoudy/AGS

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

관련 스킬