API Store Hub에서 Function Calling 및 구조화 JSON 출력
strict: true JSON Schema/Zod 검증을 통해 데이터베이스와 비즈니스 API에 바로 적재 가능한 100% 유효 JSON을 생성하세요.
API Store Hub의 단일 API 키, 투명한 요금제, 멀티 프로바이더 페일오버로 프로덕션 AI를 시작하세요.
설치 명령어
| Language | TypeScript |
|---|---|
| Runtime | Node.js 20+ / Python 3.10+, OpenAI & Anthropic SDK |
| Protocol | OpenAI Compatible (/v1/chat/completions) & Anthropic (/v1/messages) |
| 설치 명령어 | npm install openai zod |
3단계 빠른 설정 절차
- API Store Hub에서 API 키 발급: API Store Hub 콘솔에 로그인해 sk-ash- 접두사 키를 생성하고 필요 시 일/월 사용 한도를 설정하세요.
- SDK 설치 및 Base URL 설정: 공식 패키지를 설치하고 환경 변수를 https://apistorehub.com로 지정해 /v1/messages 엔드포인트를 호출합니다.
- 스트리밍 및 재시도로 호출 실행: 명시적 타임아웃과 지터 재시도로 gpt-6.2-sol를 호출하세요. 모든 요청의 토큰, TTFT, 비용이 투명하게 기록됩니다.
프로덕션 바로 적용 코드 예제
TypeScript
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://apistorehub.com/v1", apiKey: process.env.API_KEY });
const res = await client.chat.completions.create({
model: "gpt-6.2-sol",
messages: [{ role: "user", content: "Extract order: 2 keyboards at 450000 VND for Minh." }],
response_format: {
type: "json_schema",
json_schema: {
name: "order_extract",
strict: true,
schema: {
type: "object",
properties: {
customer: { type: "string" },
item: { type: "string" },
qty: { type: "integer" },
unit_price_vnd: { type: "integer" }
},
required: ["customer", "item", "qty", "unit_price_vnd"],
additionalProperties: false
}
}
}
});
console.log(JSON.parse(res.choices[0].message.content || "{}"));cURL
curl https://apistorehub.com/v1/chat/completions \
-H "Authorization: Bearer sk-ash-your_key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6.2-sol","response_format":{"type":"json_object"},"messages":[{"role":"system","content":"Return JSON only."},{"role":"user","content":"Extract city from: Giao hang tai Da Nang"}]}'추천 모델 및 실시간 요금
| 모델 | 토큰 단가 | 컨텍스트 및 엔드포인트 |
|---|---|---|
| GPT 6.2 Sol | 6,700 ST / 1M tokens | 1.1M |
| Claude Sonnet 5.5 | 7,700 ST / 1M tokens | 1M |
| Gemini 4 Neon | 20,400 ST / 1M tokens | 2M |
프로덕션 운영 체크리스트
- strict: true 사용 시 모든 중첩 객체에 additionalProperties: false와 전체 필드의 required 배열을 반드시 명시하세요.
- 긴 응답(500토큰 초과)에는 항상 stream=true를 활성화해 TTFT를 줄이고 타임아웃을 방지하세요.
- 클라이언트 코드에 API 키를 하드코딩하지 말고 서버 환경 변수로 주입하며 API Store Hub 콘솔에서 주기적으로 교체하세요.
- 429/502/529 오류에 지터 포함 지수 백오프를 적용하고 동일 API 키로 폴백 모델을 구성하세요.
자주 묻는 질문
- Function Calling & Structured JSON을(를) API Store Hub에 연동할 때 기존 호출 로직을 수정해야 하나요?
- 아니요. API Store Hub는 OpenAI(https://apistorehub.com/v1)와 Anthropic Messages(https://apistorehub.com/v1/messages) 스키마를 그대로 호환하므로 Base URL과 sk-ash- 키만 변경하면 됩니다.
- 하나의 API 키로 스트리밍, 함수 호출, 임베딩을 모두 사용할 수 있나요?
- 네. API Store Hub의 단일 키 하나로 SSE 스트리밍, 엄격한 JSON Schema, 툴 호출, 임베딩을 포함한 전체 187개 모델을 이용할 수 있습니다.
- 과금과 속도 제한은 어떻게 관리되나요?
- 모든 요청은 API Store Hub 콘솔에서 토큰 또는 요청 단위로 투명하게 과금되며 마이너스 잔액 없이 키별 지출 한도를 설정할 수 있습니다.