POST /v1/estimate는 모델과 입력으로 생성의 가격을 계산합니다. Playground와 같은 계산을 사용하며, 최종 청구액은 서버가 계산합니다. API 키가 필요하지 않고 요청 본문은 256 KiB까지입니다. 전체 스키마는 OpenAPI 정의에 있습니다.
본문은 JSON입니다.
model(필수):vendor/model형식의 모델 ID입니다. 예:sakuranbo/cherryimage-1.0-pro.input(선택): 생성 입력입니다. 가격에 영향을 주는 값만 읽으며, 생략한 값에는 모델 기본값이 사용됩니다. 각 모델의 입력 필드는 모델 페이지에 나와 있습니다.
curl -X POST "https://api.sakuranbo.ai/v1/estimate" \ -H "Content-Type: application/json" \ -d '{ "model": "sakuranbo/cherryimage-1.0-pro", "input": { "resolution": "2k" }}'const response = await fetch("https://api.sakuranbo.ai/v1/estimate", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ "model": "sakuranbo/cherryimage-1.0-pro", "input": { "resolution": "2k" } }),});const data = await response.json();console.log(data);import requests
response = requests.post( "https://api.sakuranbo.ai/v1/estimate", json={ "model": "sakuranbo/cherryimage-1.0-pro", "input": { "resolution": "2k", }, },)print(response.json())계산에 도움이 되는 선택 필드가 두 개 있습니다.
- 텍스트 모델은
prompt_tokens를 받습니다. 0 이상이고 모델의 컨텍스트 길이 이하인 정수를 지정합니다. 생략하면messages로 입력 크기를 근사합니다. 정수가 아니거나 범위를 벗어난 값은400이 되며, 조용히 근사하거나 보정하지 않습니다. - 이미지 모델은 이미지 수인
n을 받습니다. 모델 페이지에 나와 있는 범위의 정수를 지정합니다. 기본값은 1입니다. 범위를 벗어난 값은400이 됩니다.
응답에는 object: "estimate", model, currency(USD), total_micro_usd와 total_usd로 나타낸 합계, 가격 항목마다 한 개씩 담긴 lines 배열, 계산의 근거를 설명하는 assumptions 배열이 들어 있습니다.
{ "object": "estimate", "model": "sakuranbo/cherryimage-1.0-pro", "currency": "USD", "total_micro_usd": 90000, "total_usd": "0.09", "lines": [ { "dimension": "output_image", "unit": "per_image", "quantity": 1, "unit_price_micro_usd": 90000, "unit_price_usd": "0.09", "amount_micro_usd": 90000, "amount_usd": "0.09", "conditions": { "resolution": "2k" } } ], "assumptions": [ "Failed, cancelled, expired, and policy-rejected generations are not billed, except in the rare case where it cannot be confirmed that the request reached the model provider. The reserved amount then stays reserved until it is confirmed whether the request is billed." ]}텍스트 모델은 출력 쪽을 max_tokens(모델이 출력할 수 있는 최대 토큰 수)로 계산합니다. 입력 쪽은 prompt_tokens를 보내면 그 값을 쓰고, 보내지 않으면 messages로 근사하므로 합계가 상한이라고 보장하지는 않습니다. 합계를 상한으로 쓰려면 실제 입력 토큰 수를 prompt_tokens로 보내세요. 실패하거나 취소되거나 콘텐츠 정책으로 거부된 생성에는 요금이 청구되지 않습니다. 예외는 모델이 출력(추론 출력 포함)을 생성하기 시작한 뒤 끊긴 채팅 스트림이며, 생성된 출력은 과금됩니다. 채팅을 참고하세요.
400invalid_request: 본문이 올바른 JSON이 아니거나, 필드의 타입이 틀렸거나, 입력값이 범위를 벗어났습니다.error.param에 필드 이름이 담깁니다. 허용 값이 정해져 있으면error.details.allowed에 나열되고, 숫자이면error.details.minimum과error.details.maximum에 허용 범위가 담깁니다.404model_not_found: 모델 ID가 카탈로그에 없습니다.413payload_too_large: 본문이 256 KiB를 넘습니다.
전체 목록은 오류를 참고하세요.
모든 가격은 USD 기준이며, 표시 가격에는 당사의 마진이 포함되어 있습니다.