TypeSafe AI

TypeSafe AI (Jev)

TypeSafe AI의 System One API 패스스루 엔드포인트를 소개할게요. Jev는 텍스트 대신 타입이 있는 결정(선택/choice, 점수/score, 예/아니오 확률)을 반환해요. 그래서 일반적인 /chat/completions가 아니라 전용 evaluate 엔드포인트를 통해 호출됩니다. usage 정보도 그대로 반환돼요.

출처: 문서

본문

연결 대상 호스트는 https://api.typesafe.ai이고, 프록시를 통한 주소는 이렇게 구성돼요.

LITELLM_PROXY_BASE_URL/typesafe

참고로 LiteLLM 자동 라우터에서 Jev를 classifier_type: jev(또는 jev_classifier_config)로 사용할 수도 있어요. 자세한 내용은 자동 라우터 설정, 자동 라우팅, 그리고 Jev 벤치마크 블로그를 참고해 주세요.

빠른 시작 (Quick Start)

환경 변수를 설정해요.

export TYPESAFE_API_KEY=""
# optional, defaults to https://api.typesafe.ai
export TYPESAFE_API_BASE="https://api.typesafe.ai"

그다음 LiteLLM 프록시를 실행해요.

litellm
# RUNNING on http://0.0.0.0:4000

이제 System One 엔드포인트를 호출해 볼게요.

curl -X POST 'http://0.0.0.0:4000/typesafe/v1/systemone' \
-H "Authorization: Bearer ***" \
-H 'Content-Type: application/json' \
-d '{
  "state": "Help! My payouts have been failing for 3 days.",
  "model": "jev-latest",
  "questions": {
    "department": {
      "type": "choice",
      "instructions": "Which team should handle this?",
      "criteria": {
        "billing": "Payments, invoicing, refunds",
        "technical": "Bugs, outages, integrations",
        "sales": "Pricing, upgrades, new accounts"
      }
    }
  }
}'

응답은 다음과 같아요.

{
  "model": "jev-1.13.0",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "technical",
      "probabilities": {"billing": 0.08, "technical": 0.85, "sales": 0.07},
      "confidence": 0.82
    }
  },
  "usage": {"input_tokens": 312, "output_tokens": 48}
}

/typesafe/ 하위의 다른 엔드포인트(예: GET /typesafe/v1/models)도 그대로 호출할 수 있어요. 전체 API 목록은 TypeSafe API 문서를 참고해 주세요.

비용 추적 (Cost Tracking)

비용 추적은 응답의 usage.input_tokensusage.output_tokens에 기반해 typesafe/<model> 형식으로 기록돼요. 예를 들어 응답에 jev-1.13.0이 오면 실제 모델은 jev-1.13.0으로 매칭되는 식이에요. 요청 시 jev-latest, jev-preview 같은 별칭 모델명을 써도, 실제 비용은 반환된 모델 typesafe/jev-1.13.0으로 계산됩니다.

더 알아보기 (Learn more)