메인 콘텐츠로 건너뛰기

Documentation Index

Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt

Use this file to discover all available pages before exploring further.

모델 호출 전에 모델 디렉터리 가격과 엔드포인트에서 과금하는 단위(토큰(Token), 이미지, 오디오 길이, 비디오 작업)를 조합해 비용을 추정하세요. 추정값은 예산 가드로 활용하고, 요청이 완료된 후에는 실제 사용량과 청구 기록을 사용하세요.

토큰 기반 호출 추정하기

다음 Python 예시는 구성된 가격 값을 바탕으로 토큰 기반 요청 비용을 추정합니다:
import math
import os

prompt = "Write a short product description for CometAPI."
max_output_tokens = 200

input_price_per_1m = float(os.environ["MODEL_INPUT_PRICE_PER_1M"])
output_price_per_1m = float(os.environ["MODEL_OUTPUT_PRICE_PER_1M"])

estimated_input_tokens = math.ceil(len(prompt) / 4)

estimated_cost = (
    estimated_input_tokens * input_price_per_1m
    + max_output_tokens * output_price_per_1m
) / 1_000_000

print(f"Estimated maximum cost: ${estimated_cost:.6f}")
결과는 호출 전 추정값입니다:
Estimated maximum cost: $0.000123

최대 출력 예산 설정하기

다음 요청은 생성되는 출력을 제한해 추정값에 상한이 생기도록 합니다:
curl https://api.cometapi.com/v1/chat/completions \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {
        "role": "user",
        "content": "Write a short product description for CometAPI."
      }
    ],
    "max_completion_tokens": 200
  }'
응답에는 모델 호출 후 실제 사용량이 포함됩니다:
{
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 42,
    "total_tokens": 52
  }
}

작업 기반 호출 추정하기

다음 JavaScript 예시는 이미지 또는 비디오 생성과 같은 작업 기반 워크플로의 비용을 추정합니다:
const taskCount = 3;
const pricePerTask = Number(process.env.MODEL_PRICE_PER_TASK);

const estimatedCost = taskCount * pricePerTask;

console.log(`Estimated maximum cost: $${estimatedCost.toFixed(4)}`);
결과는 작업 예산입니다:
Estimated maximum cost: $0.4500

일반적인 오류

오류수정 방법
잘못된 모델의 가격 사용모델 디렉터리에서 동일한 model ID의 가격을 복사하세요.
출력 토큰(Token) 무시max_completion_tokens 또는 엔드포인트별 출력 제한을 설정하세요.
추정값을 청구서로 간주호출 후 실제 사용량과 추정값을 비교하세요.
작업 배수 누락이미지, 오디오, 비디오의 경우 작업당, 초당 또는 생성된 자산당 과금인지 확인하세요.

관련 링크

Last modified on May 28, 2026