본문으로 이동

결제와 프로젝트

결제와 사용량

결제 상태, 주문, 유료 구매 로트, 사용량, 환불을 조회하고, 실행 견적을 받고, Company 예산 한도를 올립니다. 결제는 별도 제품 API가 아니라 공통 플랫폼 기능입니다.

로컬 미리보기

계약 1의 로컬 미리보기만 제공합니다. 테스트용 요금과 결제 확인으로는 실제 결제를 증명할 수 없습니다. 전체 내보내기·삭제 수명주기도 아직 확립되지 않았습니다.

빠른 시작

신뢰할 수 있는 백엔드에서 프로젝트 자격 증명과 범위 헤더로 호출하세요. 금액은 USD 마이크로달러 정수(USD1 = 1,000,000)이고, 시각은 UTC Unix 밀리초입니다.

Headers
Authorization: Bearer <project credential>
X-Roye-Project: <projectId>
X-Roye-Environment: development
Roye-Contract-Version: 1
Content-Type: application/json

얇은 SDK의 메서드 하나는 경로 하나에 대응합니다.

billing.ts
import { Roye } from '@roye-ai/client';
const roye = new Roye({ baseURL, projectId, environment: 'development', token });
const preview = await roye.billing.preview();
const status = await roye.billing.status();
const quote = await roye.billing.quote({
  mode: definition.mode,
  participants: definition.participants.map(({ id, model, maxOutputTokens }) => ({ id, model, maxOutputTokens })),
});
const usage = await roye.billing.usage.list({ limit: 25 });
const runBill = await roye.billing.usage.getRoundtableRun(runId);
const executionBill = await roye.billing.usage.getAgentExecution(executionId);
const evaluationBill = await roye.billing.usage.getEvaluationRun(evaluationRunId);
const budget = await roye.billing.companyBudgets.get(companyId);

인증과 범위

  • 호출에는 현재 프로젝트 관리 권한이 필요하고, 리플레이할 때도 권한을 다시 확인합니다. 백엔드 키는 브라우저에 두지 마세요. Roye-Contract-Version을 빼면 계약 1로 처리합니다.
  • 코드를 사용하려면 조직 소유자가 콘솔에 로그인해야 합니다.
  • 결제 확인, 환불 결과, 결제 일시 정지·재개는 Roye 직원이 별도의 제한된 권한으로 기록합니다. 고객 자격 증명으로는 이 권한을 얻을 수 없습니다.

응답 필드

주문, 로트, 프로모션 지급, 환불, 사용량에는 id와 scope도 있습니다.

리소스필드
상태currency, fundingState, reason, supportEmail, packsUsd, available/held/refundHeld/used/expired/refundedMicros, expiryPending, liabilityState
주문organizationId, packUsd, amountMicros, currency, state, lotId, created/confirmedAt
유료 구매 로트orderId, purchasedAt, expiresAt, granted/available/held/used/refundHeld/refunded/expired/reversedMicros
프로모션 지급currency, grantedAt, expiresAt, granted/available/held/used/expiredMicros
환불lotId, orderId, amount/payout/roundingCost/originalRoutePayout/residualMicros, state, route, requested/due/escalate/updatedAt, originalRouteUntil
사용량source, 폐기 예정(deprecated)인 original, currency, maximum/held/charged/releasedMicros, pricing(참가자 8명 이하인 원본에만 있음), state(reserved/pending/settled/waived), reason(completed/cancelled/failed/unknown_deadline 또는 null), companyId, created/release/settledAt
Company 예산companyId, scope, currency, limit/packageLimit/held/chargedMicros, revision, created/updatedAt
  • 주문을 만들거나 환불을 요청하거나 코드를 사용하면 201, 조회하면 200을 받습니다. 응답은 감싸지 않은 리소스 객체입니다.
  • packUsd, packsUsd, supportEmail, 미리보기 한도, 환불 route는 서버 정책이 정합니다. 사용량 source와 마찬가지로 처음 보는 값도 버리지 마세요. 요청에는 정책에 있는 값만 보낼 수 있습니다.

견적

POST /v1/billing/quote는 조회 전용입니다. 금액을 보류하지 않고 실행 권한도 주지 않습니다.

형식본문
Roundtable(module 없음 또는 roundtable)mode(single, opening, parallel)와 서로 다른 참가자 participants 1~8명(id, model, maxOutputTokens). single은 한 명만 받습니다.
Agents(module: "agents")실행할 정의 리비전의 profile, model, maxOutputTokens(리비전의 defaults.maxOutputTokens). 참가자 agent 한 명의 가격을 계산합니다.

응답에는 maximumMicros, policyRevision과 참가자별 모델, 요율 리비전, 캐시 처리 방식, 토큰 한도, 유리수로 된 unitMicros 요율이 들어 있습니다. 카탈로그와 정책이 그대로라면 Agents 견적의 maximumMicros는 실행이 접수된 뒤 보류하는 금액과 같습니다.

quote.http
POST /v1/billing/quote
{"module":"agents","profile":{"id":"structured","revision":"1"},
 "model":"<definition model>","maxOutputTokens":1024}
quote.ts
// revision: the Agents definition revision the execution will run
const quote = await roye.billing.quote({
  module: 'agents',
  profile: revision.profile,
  model: revision.model,
  maxOutputTokens: revision.defaults.maxOutputTokens,
});
// After admission the execution holds the same maximum.
const bill = await roye.billing.usage.getAgentExecution(executionId);
// bill.maximumMicros === quote.maximumMicros
// bill.source: { module: 'agents', type: 'execution', id: executionId }

카탈로그에 없는 Agents profile이나 다른 module을 보내면 unsupported_capability를 받습니다. 검증된 가격이나 선의 면제(goodwill) 재원이 없으면 not_ready를 받습니다.

팩, 로트, 프로모션 지급

  • 기본 팩은 USD 10, 30, 100(packsUsd)이고 서비스 가치는 같습니다. 구독이나 자동 충전은 없습니다.
  • 주문만 해서는 결제가 이뤄지거나 크레딧이 생기지 않습니다. 확인된 주문의 유료 구매 로트는 구매 후 UTC 기준 12개월 뒤 만료되며, 2월 29일은 28일로 맞춥니다. 확인 지연, 재시도, 재생성으로 기한이 늘지 않습니다.
  • 프로모션 지급은 별도 크레딧입니다. 현금으로 환불되지 않고 구매할 수도 없으며, 지급 후 UTC 기준 1년 뒤 만료됩니다. 사용 금액은 쓸 수 있는 프로모션 지급분부터 차감합니다.
  • 유료 주문을 할 수 있는지는 프로모션 지급이 아니라 credits 목록 응답의 purchasesAvailable로 판단합니다.
  • expiryPending과 liabilityState: blocked는 더 진행하지 않도록 막아 둔 상태입니다.

환불

환불을 요청하면 원래 로트에서 쓰지 않았고 보류되지 않은 유료 금액을 잡아 둡니다. accepted는 지급 완료가 아닙니다.

규칙값
대상구매 후 150일 이내.
처리 목표UTC 기준 월~금 영업일 5일.
에스컬레이션구매 165일째, 또는 그 전에 거절이나 처리 불가가 확인되면.
원래 결제 경로PayPal 경로의 180일 기한이 지나도 채무는 사라지지 않습니다.
올림지급액은 센트 단위로 올리고, 차액은 Roye가 부담합니다.
잔여 채무originalRoutePayoutMicros는 원래 경로로 지급할 수 있는 금액입니다. residualMicros는 계속 갚아야 할 금액이며, 그 경로로 임의 지급하거나 없애지 않습니다.
대기 또는 불명중복 지급하지 않습니다.
은행 송금 예외동의, 원래 결제자 본인 계좌 확인, 원래 경로로 완료할 수 없다는 증거, 별도 송금 권한이 모두 필요합니다.
결제 취소(reversal)채무는 그대로 남습니다.
문의support@roye.ai 이메일로만 받습니다. 첫 답변 목표는 UTC 영업일 2일입니다.

Company 예산

  • Company마다 공유 누적 한도와 패키지별 한도가 있고, 기본값은 각각 USD 5이며 공급자 안전 한도와는 별개입니다. 달력 기준 초기화, 자동 충전, 한도 인하는 없고, 합계는 계산값일 뿐 청구가 아닙니다.
  • 한도는 현재 프로젝트 권한이 있는 조직 소유자만 올릴 수 있고, 리플레이할 때도 마찬가지입니다. 마이크로달러 정수와 현재 expectedRevision을 보내세요. 리비전이 오래되면 409 revision_conflict를 받습니다. 한도를 올리는 요청만 받습니다.

엔드포인트

미리보기를 뺀 경로는 모두 /v1/billing으로 시작합니다. 견적을 뺀 POST는 idempotencyKey를 받습니다.

경로용도
GET /v1/projects/:projectId/:environment/billing/preview누적 단위, 콘텐츠 바이트, 사용 중인 Company와 직원 자리.
GET /status결제 상태와 잔액.
GET /credits[/:id]프로모션 지급.
POST /redemptionscode를 사용하고 redemption과 credit을 돌려줍니다.
POST /orders목록에 있는 팩을 주문합니다.
GET /orders[/:id]주문.
GET /lots[/:id]유료 구매 로트.
POST /refundslotId에서 0보다 큰 amountMicros를 요청합니다.
GET /refunds[/:id]환불.
GET /usage[/:id]원래 사용량.
GET /usage/roundtable/:runIdRoundtable 실행 하나의 사용량.
GET /usage/agents/:executionIdAgents 실행 하나의 사용량.
GET /usage/evaluations/:runIdEvaluations 실행 하나의 사용량. 모델 호출을 계획하지 않은 실행은 not_found.
GET /company-budgets/:companyIdCompany 한도.
POST /company-budgets/:companyId/raiseexpectedRevision, limitMicros, packageLimitMicros.
POST /quote정확한 요율과 보수적으로 잡은 최대 금액.

SDK의 변경 메서드는 다른 플랫폼 호출처럼 인텐트를 저장하고 복구합니다. SDK는 결제를 실행하지 않습니다.

funding.ts
const order = await roye.billing.orders.create({ packUsd: 10, idempotencyKey: 'purchase-1' });
const lots = await roye.billing.lots.list({ limit: 25 });
// Use a verified original lot ID; acceptance reserves funds, it does not send money.
const refund = await roye.billing.refunds.request({
  lotId: originalLotId, amountMicros: 1000000, idempotencyKey: 'refund-1',
});

제한

항목값
목록limit 1~25. cursor는 최대 512자이며 받은 값을 그대로 보냅니다. 페이지는 items와 next를 돌려줍니다.
식별자URL에 쓸 수 있는 문자 1~80자. 참조와 사유는 1~120자.
견적 출력maxOutputTokens 1~2,048.
프로젝트 미리보기원본 1,000단위와 콘텐츠 10 MiB. 두 환경이 함께 씁니다.
Company와 직원활성 Company 1개와 직원 자리 4개(제안, 고용, 일시 정지, 종료 진행 중). 제안을 철회하거나 임명이 끝나면 자리가 돌아옵니다.

알 수 없는 본문 필드와 반복되거나 지원하지 않는 쿼리는 거부합니다.

오류

오류는 공통 오류 형식을 씁니다. 없는 리소스와 접근할 수 없는 리소스는 모두 not_found입니다. 오류가 났거나 목록이 비어 있어도 공급자 비용이 0이라는 뜻은 아닙니다.

코드HTTP할 일
invalid_request, bounds_exceeded, payload_limit400, 400, 413금액, 팩, 페이지, 헤더를 고치세요.
contract_version_unsupported, unsupported_capability400제공되는 계약이나 기능을 쓰세요.
unauthorized, credential_expired, credential_revoked, forbidden, authority_revoked401, 403현재 범위의 권한을 얻으세요.
not_found404범위 안의 ID인지 확인하세요. 다른 테넌트를 조회하지 마세요.
idempotency_conflict409원래 입력을 복구하세요. 바뀐 입력에 같은 키를 쓰지 마세요.
invalid_transition, binding_invalid, effect_unresolved409원래 증거를 확인하세요. 원래 지급이 pending이나 unknown이면 그 경로가 거절될 때까지 예외 경로를 쓸 수 없습니다.
budget_exhausted, not_ready409상태, 보류되지 않은 금액, 채무, 원래 로트를 조회하세요.
operation_pending, operation_replay_expired202, 410원래 키로 원래 호출을 조회하거나 복구하세요.
rate_limited, unavailable429, 503허용된 경우에만 같은 입력과 키로 재시도하세요.
promotion_unavailable, promotion_already_redeemed409promotion_unavailable은 코드나 프로모션이 중지됐거나 기간이 끝났거나 소진된 경우이고, promotion_already_redeemed는 이 조직이나 사용자가 이미 사용한 경우입니다. 더 충전되지 않습니다.

복구

보내기 전에 프로젝트, 환경, module platform, 호출 종류, 대상, idempotencyKey, 정확한 입력을 저장하세요.

종류대상
billing.orders.create빈 대상
billing.redemptions.create빈 대상
billing.refunds.request원래 lotId
billing.company_budgets.raisecompanyId
  • 같은 키와 입력으로 보내면 원래 응답을 Roye-Replayed: true와 함께 다시 돌려줍니다. 입력이 바뀌면 충돌합니다.
  • 응답을 잃었다면 다른 일을 하기 전에 원래 범위와 대상으로 operations.recover를 호출하세요. 키, 본문, 리비전은 그대로 둡니다.
  • 응답이 없거나 상태가 unknown이어도 새로 결제하거나 환불할 근거가 되지 않습니다.
  • 호출 이력이 만료된 뒤에도 영구 원본 명령은 리플레이되며, 사용량을 다시 채우지 않습니다.
recovery.http
POST /v1/operations/recover
{"module":"platform","kind":"billing.refunds.request",
 "target":{"lotId":"<originalLotId>"},"idempotencyKey":"refund-1"}

POST /v1/billing/refunds
{"idempotencyKey":"refund-1","lotId":"<originalLotId>","amountMicros":1000000}

사용량

사용량 기록 하나는 고객 원본 하나이며, 공급자 채무와 따로 관리합니다. 고정된 pricing 스냅숏은 원본의 참가자가 8명 이하일 때만 남습니다. 호출이 8개를 넘는 Evaluations 실행처럼 그보다 큰 원본에는 pricing이 없습니다. source는 Roundtable 실행이면 { module: "roundtable", type: "run", id }, Agents 실행이면 { module: "agents", type: "execution", id }, Evaluations 실행이면 { module: "evaluations", type: "run", id }입니다. 다른 모듈 코드도 올 수 있습니다.

결과를 모르는 고객 보류 금액은 원래 기한인 72시간 안에 Roye가 부담하는 선의 면제(goodwill)로 풀어 줍니다. 공급자 쪽 미확정 채무는 따로 보존하며, 나중에 들어온 사실로 고객 청구를 다시 만들지 않습니다.

모델을 쓰지 않는 미리보기는 실제 결과를 만드는 변경을 한 번씩 셉니다. Communication은 수신자별 전달마다, Automation은 결과를 만든 실행 항목마다 셉니다. 제한된 원본 복사는 한 번만 세고, 새 콘텐츠는 접수를 거쳐야 합니다. 삭제하거나 리플레이하거나 시간이 지나도 다시 채워지지 않습니다. 조회, 중지, 정리는 계속 쓸 수 있으며, 미리보기는 요금이나 모델 실행 권리를 만들지 않습니다.