C
Claude API 가이드

TokenHub의 Claude — OpenAI-Compatible Anthropic model

TokenHub의 통합 /chat/completions 엔드포인트를 통해 Anthropic Claude model을 호출하세요. 요청 및 응답 형식은 완전히 OpenAI-compatible하므로 SDK 이전이 필요 없습니다. Streaming, tool 사용(function calling), vision(이미지 입력)을 모두 지원합니다. 과금은 model 티어별 per-token 기준입니다.

OpenAI-CompatibleStreamingTool UseVisionClaude 3 → 4.7Token-based

1API Key 받기

  1. 다음으로 이동 tokenhub.store 하고 계정을 등록하세요 (GitHub / Google 로그인 지원)
  2. Dashboard → API Keys로 이동한 뒤 "Create New Key"를 클릭하세요
  3. Dashboard → Billing으로 이동해 Credits를 추가하세요 (1 Credit = $1 USD)
  4. API Key를 복사하세요 (형식: th-xxxxxxxxxxxx...)
⚠️ API Key는 생성 시 한 번만 표시됩니다. 안전하게 보관하세요. 분실한 경우 새로 생성해야 합니다.

2API 개요

Base URL

https://tokenhub.store/api/v1

인증

Authorization 헤더에 API Key를 전달하세요:

Header
Authorization: Bearer th-your-api-key

엔드포인트 (OpenAI-compatible)

POST
/chat/completions

채팅 완료. streaming, tool use, vision, JSON mode를 포함해 OpenAI /v1/chat/completions와 동일한 스키마입니다.

공식 openai SDK를 그대로 사용할 수 있습니다. base_url만 TokenHub로 지정하고 TokenHub API Key를 사용하세요. 다른 코드 변경은 필요하지 않습니다.

3모델 및 요금

요금은 100만 tokens당 USD 기준입니다. 성공한 호출에만 요금이 부과됩니다. 정식 ID와 anthropic/* 별칭을 모두 지원합니다.

티어모델 ID입력출력비고
Opus 4.7anthropic/claude-opus-4-7$5.00$25.00최신, 최고 품질의 reasoning 및 coding.
Opus 4.6anthropic/claude-opus-4-6$5.00$25.00최신, 최고 품질의 reasoning 및 coding.
Sonnet 4.6anthropic/claude-sonnet-4-6$3.00$15.00품질과 비용의 균형이 뛰어난 대표 모델 (권장 기본값).
Haiku 4.5anthropic/claude-haiku-4-5$1.00$5.00가장 빠르고 저렴한 4-gen 모델; 고QPS 및 분류 작업에 적합합니다.
Sonnet 4.5anthropic/claude-sonnet-4-5$3.00$15.00이전 세대의 범용 작업용 주력 모델.
Opus 4.5anthropic/claude-opus-4-5$5.00$25.00최신, 최고 품질의 reasoning 및 coding.
Sonnet 4anthropic/claude-4-sonnet$3.00$15.00이전 세대의 범용 작업용 주력 모델.
Opus 4anthropic/claude-4-opus$15.00$75.00최신, 최고 품질의 reasoning 및 coding.
3.5 Sonnetanthropic/claude-3-5-sonnet-latest$3.00$15.00안정적이며 실전 검증 완료; 폭넓게 호환됩니다.
3.5 Haikuanthropic/claude-3-5-haiku-latest$0.80$4.00안정적이며 실전 검증 완료; 폭넓게 호환됩니다.

4요청 파라미터

파라미터타입필수 여부기본값설명
modelstring필수Claude model ID. 예: "anthropic/claude-sonnet-4-6". anthropic/* 접두사가 있는 형식과 짧은 이름 형식 모두 허용됩니다.
messagesarray필수채팅 기록입니다. 각 항목은 { role, content } 형식입니다. role ∈ system | user | assistant. content는 문자열 또는 파트 배열입니다 (vision / tool 결과용).
max_tokensinteger선택1024최대 출력 tokens (Claude에서는 필수). 일반적으로 1024–4096입니다.
temperaturenumber선택1.0샘플링 temperature, 0.0–1.0. 낮을수록 더 결정적입니다.
top_pnumber선택1.0핵심 샘플링입니다. temperature 또는 top_p 중 하나만 사용하세요. 둘 다 사용하지 마세요.
streamboolean선택falsetrue이면 Server-Sent Events (SSE) 델타를 반환합니다.
stopstring[]선택최대 4개의 중지 시퀀스를 지정할 수 있습니다.
toolsarray선택tool use (function calling)을 위한 tool/function 정의 목록입니다.
tool_choicestring|object선택autotool 선택을 제어합니다: auto | none | required | { type:'function', function:{ name } }.
response_formatobject선택JSON mode: { "type": "json_object" } forces the model to return valid JSON.
userstring선택자체 추적용 선택적 최종 사용자 ID입니다.

5curl 예제

bash
curl https://tokenhub.store/api/v1/chat/completions \
  -H "Authorization: Bearer th-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-6",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain CAP theorem in 3 bullets."}
    ],
    "max_tokens": 512,
    "temperature": 0.3
  }'

6Python 예제

python
from openai import OpenAI

client = OpenAI(
    api_key="th-your-api-key",
    base_url="https://tokenhub.store/api/v1",
)

resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-6",
    max_tokens=512,
    temperature=0.3,
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain CAP theorem in 3 bullets."},
    ],
)

print(resp.choices[0].message.content)
print("usage:", resp.usage)

7JavaScript / Node.js 예제

javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "th-your-api-key",
  baseURL: "https://tokenhub.store/api/v1",
});

const resp = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4-6",
  max_tokens: 512,
  temperature: 0.3,
  messages: [
    { role: "system", content: "You are a concise assistant." },
    { role: "user", content: "Explain CAP theorem in 3 bullets." },
  ],
});

console.log(resp.choices[0].message.content);
console.log("usage:", resp.usage);

8사용 팁

  • 항상 max_tokens를 설정하세요 — Claude는 이를 의미상 필수로 처리합니다. 설정하지 않으면 긴 생성 결과가 예상보다 일찍 잘릴 수 있습니다.
  • 지침은 하나의 system message에 넣고, user 턴은 간결하게 유지하세요. Claude는 system 프롬프트를 강하게 따릅니다.
  • 구조화된 추출에는 'Return only JSON' 같은 system 프롬프트와 response_format: { type: 'json_object' }를 함께 사용하세요.
  • 스트리밍은 긴 응답에서 체감 지연을 크게 줄여줍니다. delta 형식은 OpenAI와 정확히 동일합니다.
  • Haiku-4-5는 Sonnet-4-6보다 약 5배 저렴하면서 짧은 작업에는 비슷한 성능을 제공합니다 — 간단한 질의는 Haiku로 라우팅해 비용을 절감하세요.
  • 비전: content 배열 안에 { type: 'image_url', image_url: { url: 'https://...' } } 형식으로 이미지를 전달하세요. Data URI(base64)도 지원됩니다.

9FAQ

시작할 준비가 되셨나요?

TokenHub에 가입하고 OpenAI-compatible API로 Claude를 바로 사용해 보세요