본문으로 건너뛰기

Cencori

Cencori 어댑터는 기본 제공되는 보안, 관찰 가능성 및 비용 추적 기능을 갖춘 통합 인터페이스를 통해 14개 이상의 AI 제공업체(OpenAI, Anthropic, Google, xAI 등)에 액세스할 수 있게 합니다.

설치

npm install @cencori/ai-sdk

기본 사용법

// ignore: @cencori/ai-sdk/tanstack is a subpath export; kiira's paths["*"] wildcard maps it
// to a flat directory lookup and does not consult the package.json exports field,
// so the subpath cannot be resolved until kiira.config.ts adds an explicit path entry.
import { chat } from "@tanstack/ai";
import { cencori } from "@cencori/ai-sdk/tanstack";

const adapter = cencori("o1");

for await (const chunk of chat({
adapter,
messages: [{ role: "user", content: "Hello!" }],
})) {
if (chunk.type === "TEXT_MESSAGE_CONTENT") {
console.log(chunk.delta);
}
}

구성

// ignore: @cencori/ai-sdk/tanstack subpath not resolvable via kiira's paths["*"] wildcard.
import { createCencori } from "@cencori/ai-sdk/tanstack";

const myCencori = createCencori({
apiKey: process.env.CENCORI_API_KEY!,
baseUrl: "https://cencori.com", // Optional
});

const adapter = myCencori("o1");

스트리밍

// ignore: @cencori/ai-sdk/tanstack subpath not resolvable via kiira's paths["*"] wildcard.
import { chat } from "@tanstack/ai";
import { cencori } from "@cencori/ai-sdk/tanstack";

const adapter = cencori("claude-3-5-sonnet");

for await (const chunk of chat({
adapter,
messages: [{ role: "user", content: "Tell me a story" }],
})) {
if (chunk.type === "TEXT_MESSAGE_CONTENT") {
process.stdout.write(chunk.delta);
} else if (chunk.type === "RUN_FINISHED") {
console.log("\nDone");
}
}

도구 호출

// ignore: @cencori/ai-sdk/tanstack subpath not resolvable via kiira's paths["*"] wildcard.
import { chat, toolDefinition } from "@tanstack/ai";
import { cencori } from "@cencori/ai-sdk/tanstack";
import { z } from "zod";

const adapter = cencori("o1");

const getWeatherDef = toolDefinition({
name: "getWeather",
description: "Get weather for a location",
inputSchema: z.object({ location: z.string() }),
});

const getWeather = getWeatherDef.server(async ({ location }) => {
// Look up the weather for `location`
return { temperature: 72, conditions: "Sunny" };
});

for await (const chunk of chat({
adapter,
messages: [{ role: "user", content: "What's the weather in NYC?" }],
tools: [getWeather],
})) {
if (chunk.type === "TOOL_CALL_START") {
console.log("Tool call:", chunk.toolCallName);
} else if (chunk.type === "TOOL_CALL_END") {
console.log("Tool call finished:", chunk.toolCallId);
}
}

다중 제공업체 지원

하나의 매개변수로 제공업체를 전환합니다.

// ignore: @cencori/ai-sdk/tanstack subpath not resolvable via kiira's paths["*"] wildcard.
import { cencori } from "@cencori/ai-sdk/tanstack";

// OpenAI-compatible
const openaiCompat = cencori("o1");

// Anthropic
const anthropic = cencori("claude-3-5-sonnet");

// Google
const google = cencori("gemini-2.5-flash");

// xAI
const grok = cencori("grok-3");

// DeepSeek
const deepseek = cencori("deepseek-v3.2");

제공업체와 관계없이 모든 응답은 동일한 통합 형식을 사용합니다.

지원 모델

Provider모델
OpenAIgpt-5, gpt-4o, gpt-4o-mini, o3, o1
Anthropicclaude-opus-4, claude-sonnet-4, claude-3-5-sonnet
Googlegemini-3-pro, gemini-2.5-flash, gemini-2.0-flash
xAIgrok-4, grok-3
Mistralmistral-large, codestral, devstral
DeepSeekdeepseek-v3.2, deepseek-reasoner
+ 기타Groq, Cohere, Perplexity, Together, Qwen, OpenRouter

참고: Cencori는 외부 패키지이며 카탈로그는 시간이 지나면서 변경됩니다. 위 모델 ID를 사용하기 전에 Cencori의 현재 카탈로그에서 확인합니다.

환경 변수

CENCORI_API_KEY=csk_your_api_key_here

API 키 받기

  1. Cencori로 이동합니다.
  2. 계정을 만들고 API 키를 생성합니다.
  3. 환경 변수에 추가합니다.

Cencori를 사용하는 이유

  • 🔒 보안 — PII 필터링, jailbreak 감지, 콘텐츠 조정
  • 📊 관찰 가능성 — 요청 로그, 지연 시간 지표, 비용 추적
  • 💰 비용 제어 — 예산, 알림, 경로별 분석
  • 🔌 다중 제공업체 — 하나의 API 키로 14개 이상의 AI 제공업체 사용
  • 🛠️ 도구 호출 — 제공업체 전반에서 함수 호출 완전 지원
  • 🔄 장애 조치 — 대체 제공업체로 자동 재시도 및 대체

API 참조

cencori(model)

환경 변수를 사용해 Cencori 어댑터를 생성합니다.

매개변수:

  • model - 모델 이름(예: "gpt-4o", "claude-3-5-sonnet", "gemini-2.5-flash")

반환값: Cencori TanStack AI 어댑터 인스턴스입니다.

createCencori(config)

사용자 지정 Cencori 어댑터 팩토리를 생성합니다.

Parameters:

  • config.apiKey - Cencori API 키
  • config.baseUrl? - 사용자 지정 기본 URL(선택 사항)

반환값: 특정 모델의 어댑터 인스턴스를 생성하는 함수입니다.

다음 단계