이 가이드에서는 새 계정을 만들어 첫 생성을 실행하기까지의 과정을 안내합니다. 계정과 API 키를 만들고, 잔액을 충전하고, 채팅 요청을 보낸 뒤 잔액을 확인합니다. 기본 URL은 https://api.sakuranbo.ai/v1입니다.
1. 계정 만들기
섹션 제목: “1. 계정 만들기”대시보드에서 회원가입을 합니다. 회원가입 화면의 안내에 따라 진행하세요.
2. API 키 만들기
섹션 제목: “2. API 키 만들기”대시보드의 API 키 페이지를 열어 키를 만듭니다. 키에 이름을 붙입니다. 사용 한도와 만료일도 설정할 수 있습니다. 잔액과 API 키 사용 한도를 참고하세요.
대시보드는 키를 만든 직후에 전체 키를 한 번만 표시합니다. 그때 복사하세요. 키는 cherry_로 시작합니다. 키를 환경 변수 SAKURANBO_API_KEY에 보관하세요. 이 문서의 모든 예시가 이 변수를 읽습니다.
export SAKURANBO_API_KEY="paste-your-key-here"키를 클라이언트 측 코드나 공개 저장소에 넣지 마세요. 인증을 참고하세요.
3. 잔액 충전하기
섹션 제목: “3. 잔액 충전하기”대시보드의 충전 페이지를 열어 카드나 암호화폐로 잔액을 충전합니다. 이 페이지에 사용할 수 있는 결제 수단이 표시됩니다. 최소 충전 금액은 기본적으로 $10.00입니다. 자세한 내용은 요금과 과금을 참고하세요.
4. 채팅 요청 보내기
섹션 제목: “4. 채팅 요청 보내기”API 키와 함께 POST /v1/chat/completions 엔드포인트에 요청을 보냅니다. 이 예시에서 사용하는 모델은 sakuranbo/cherrytext-1.0-flash입니다.
curl -X POST "https://api.sakuranbo.ai/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $SAKURANBO_API_KEY" \ -d '{ "model": "sakuranbo/cherrytext-1.0-flash", "messages": [ { "role": "system", "content": "You are a concise assistant." }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines." } ], "max_tokens": 2048}'const response = await fetch("https://api.sakuranbo.ai/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.SAKURANBO_API_KEY}`, }, body: JSON.stringify({ "model": "sakuranbo/cherrytext-1.0-flash", "messages": [ { "role": "system", "content": "You are a concise assistant." }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines." } ], "max_tokens": 2048 }),});const data = await response.json();console.log(data);import os
import requests
response = requests.post( "https://api.sakuranbo.ai/v1/chat/completions", headers={ "Authorization": f"Bearer {os.environ['SAKURANBO_API_KEY']}", }, json={ "model": "sakuranbo/cherrytext-1.0-flash", "messages": [ { "role": "system", "content": "You are a concise assistant.", }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines.", }, ], "max_tokens": 2048, },)print(response.json())OpenAI SDK로도 같은 요청을 보낼 수 있습니다. SDK의 기본 URL을 https://api.sakuranbo.ai/v1로, API 키를 Sakuranbo AI 키로 설정하세요.
TypeScript용 OpenAI SDK:
import OpenAI from "openai";
const apiKey = process.env.SAKURANBO_API_KEY;if (!apiKey) throw new Error("Set the SAKURANBO_API_KEY environment variable.");
const client = new OpenAI({ baseURL: "https://api.sakuranbo.ai/v1", apiKey,});
const completion = await client.chat.completions.create({ model: "sakuranbo/cherrytext-1.0-flash", messages: [ { role: "system", content: "You are a concise assistant." }, { role: "user", content: "Summarize the benefits of prepaid API credits in two lines." } ], max_tokens: 2048});
console.log(completion.choices[0]?.message.content);Python용 OpenAI SDK:
import os
from openai import OpenAI
client = OpenAI( base_url="https://api.sakuranbo.ai/v1", api_key=os.environ["SAKURANBO_API_KEY"],)
completion = client.chat.completions.create( model="sakuranbo/cherrytext-1.0-flash", messages=[ { "role": "system", "content": "You are a concise assistant.", }, { "role": "user", "content": "Summarize the benefits of prepaid API credits in two lines.", }, ], max_tokens=2048,)
print(completion.choices[0].message.content)응답은 chat completion 객체입니다. 생성된 텍스트는 choices[0].message.content에 들어 있습니다. usage에는 토큰 수와 요청에 든 금액인 usage.cost가 들어 있습니다. usage.cost에는 micro USD 단위의 금액이 amount_micro_usd로, 십진수 문자열 금액이 amount_usd로 들어 있습니다.
5. 잔액 확인하기
섹션 제목: “5. 잔액 확인하기”GET /v1/balance 엔드포인트로 잔액을 읽습니다.
curl "https://api.sakuranbo.ai/v1/balance" \ -H "Authorization: Bearer $SAKURANBO_API_KEY"const response = await fetch("https://api.sakuranbo.ai/v1/balance", { headers: { Authorization: `Bearer ${process.env.SAKURANBO_API_KEY}`, },});const data = await response.json();console.log(data);import os
import requests
response = requests.get( "https://api.sakuranbo.ai/v1/balance", headers={ "Authorization": f"Bearer {os.environ['SAKURANBO_API_KEY']}", },)print(response.json())available_usd는 새 요청에 사용할 수 있는 금액입니다. held_usd는 실행 중인 요청이 확보해 둔 금액입니다. 방금 보낸 요청은 이미 끝났으므로 확보했던 금액은 해제되었고, 요청에 든 금액은 available_usd에서 이미 차감되어 있습니다.
다음 단계
섹션 제목: “다음 단계”모든 가격은 USD 기준이며, 표시 가격에는 당사의 마진이 포함되어 있습니다.