앱과 템플릿
TypeScript로 게시된 Nodaro 앱을 둘러보고 실행하고, 실행 기록을 읽고, 워크플로 템플릿을 프로젝트에 복제하고, 튜토리얼을 나열하세요.
client.apps는 게시된 앱, 즉 입력과 출력으로 된 간단한 양식으로 감싼 워크플로를 둘러보고 실행합니다. client.templates는 템플릿 마켓플레이스를 둘러보고 템플릿을 내 프로젝트 중 하나에 복제하며, client.tutorials는 튜토리얼 동영상과 튜토리얼 워크플로를 나열합니다. 개념은 앱과 튜토리얼과 템플릿을 참조하세요.
메서드
| 메서드 | 하는 일 |
|---|---|
apps.list(params?) | 게시된 앱 둘러보기 |
apps.get(slug) | 앱과 그 입력, 출력 읽기 |
apps.run(slug, inputs?, opts?) | 앱 실행 |
apps.listRuns(slug, params?) | 앱의 내 실행 나열 |
apps.getRun(slug, runId) | 실행 하나 읽기 |
apps.resume(slug, runId, opts?) | 실패한 실행을 멈춘 지점부터 다시 시도 |
apps.deleteRun(slug, runId) | 실행 보관 |
templates.browse(params?) | 템플릿 마켓플레이스 둘러보기 |
templates.get(slug) | 템플릿과 그 워크플로 읽기 |
templates.clone(slug, params) | 템플릿을 프로젝트에 복사 |
tutorials.list() | 카테고리별 튜토리얼 나열 |
client.apps
list()와 get()은 공개되어 있습니다. run()과 실행 기록은 로그인한 호출자로서 작동합니다.
apps.list(params?)
게시된 앱을 한 페이지씩 둘러봅니다.
list(params?: { search?: string; category?: string; limit?: number; cursor?: string }): Promise<{
data: PublishedApp[]
nextCursor?: string | null
}>속성
타입
const { data: apps, nextCursor } = await client.apps.list({ search: "headshot", limit: 20 })이 메서드는 GET /v1/apps/browse를 호출합니다. 앱 페이지를 숨기는 배포 환경(nav.hide에 apps가 있음)에서는 둘러보기에 앱이 나열되지 않습니다: { data: [], nextCursor: null }. 배포 환경은 공개 작업을 끌 수 있습니다(outputs.allowPublic: false). 그런 곳에서는 마켓플레이스에 아무것도 나열되지 않습니다: { data: [], nextCursor: null }. 그리고 앱은 만든 사람만 쓸 수 있습니다. 다른 사람의 앱에 get(), run(), resume()을 호출하면 존재하지 않는 앱처럼 NotFoundError가 발생합니다. 그 앱을 직접 실행한 지난 기록은 listRuns()와 getRun()으로 계속 읽을 수 있습니다.
PublishedApp에는 id, slug, name, description, creatorId, creatorName, thumbnailUrl, category, isFeatured, runCount, estimatedCredits, perMinuteCredits, perItemCredits, createdAt, updatedAt이 있습니다.
estimatedCredits는 앱의 실행당 표시 가격입니다. 어떤 앱은 입력받는 녹음의 길이에 따라 가격이 정해집니다. 예를 들어 편집 계획 단계나 에피소드 전체의 렌더링입니다. 이런 앱은 perMinuteCredits가 0보다 크며, 가격은 estimatedCredits에 녹음 1분마다 perMinuteCredits를 더한 값입니다. 앱에 사용자가 채우는 목록 입력이 있으면 perItemCredits가 0보다 큽니다. 제작자가 저장한 항목을 넘는 항목마다 그만큼의 크레딧이 더해집니다.
앱 사용자가 고를 수 있는 선택지가 더 비싸면 표시 가격은 범위가 됩니다. maxEstimatedCredits는 maxPerMinuteCredits, maxPerItemCredits와 함께, 제작자가 정한 제한 안에서 앱이 노출한 필드로 실행 한 번에 들 수 있는 최대 가격입니다. estimatedCredits와 그 구성 요소는 저장된 설정의 가격, 즉 "부터" 가격입니다. max* 필드는 값이 다를 때만 있습니다. UGC 동영상은 조합마다 다시 가격이 매겨지므로, 앱 사용자가 고를 수 있는 스크립트 길이나 언어는 가장 높은 가격으로 계산됩니다. 범위가 생기기 전에 게시된 앱에는 다음에 게시할 때까지 이 필드가 없습니다.
estimatedCreditsIsEstimate: true는 사용량 기반 LLM 호출의 예상 가격이 들어 있는 표시 가격을 나타냅니다. 앱, 템플릿, 튜토리얼에 담깁니다. LLM 호출은 실제 사용량만큼 토큰당 청구되므로, 가격을 ≈N으로 표시하세요. 고정 가격에는 이 필드가 없습니다. 워크플로가 아직 가격이 없는 LLM 모델을 지정한 게시는 400 validation_error와 reason: "llm_model_unpriced"로 거부됩니다. 아직 가격이 없는 모델을 참조하세요. 저장된 설정에서든, 앱 사용자가 고를 수 있는 선택지에서든 UGC 동영상의 가격을 매기지 못한 게시는 절대 무료로 등록되지 않습니다. 이 게시는 503으로 거부되며, 코드와 reason은 ugc_listing_unpriced이고, 실패한 항목을 가리키는 choice가 함께 옵니다. 예: "a choice its users can make (Hebrew, 60 s)". 아무것도 저장되지 않으므로 다시 게시하세요. SDK로 읽으면 그 code와 status를 가진 NodaroError입니다.
apps.get(slug)
앱 하나를 읽습니다. 최종 사용자가 채우는 필드인 inputSchema와 앱이 반환하는 것인 outputs가 함께 들어 있습니다.
get(slug: string): Promise<{ data: PublishedAppDetail }>속성
타입
const { data: app } = await client.apps.get("pro-headshot")
console.log(app.inputSchema, app.outputs) // outputs: [{ nodeId, label, type }]runEstimatedCredits, runPerMinuteCredits, runPerItemCredits는 앱 실행만의 가격입니다. 표시 가격에서 최종 렌더링 부분을 뺀 값이며, 최종 렌더링은 따로 실행되고 따로 청구됩니다. editPlanPerMinute는 편집 계획 노드가 녹음의 시작된 1분마다 청구되면 true이고, 15, 30, 60, 90, 120, 180분 단위로 청구되면 false입니다.
apps.run(slug, inputs?, opts?)
앱을 실행하고 { executionId, status, runId? }를 즉시 반환합니다. 결과는 client.executions.get(executionId)를 폴링해 받으세요.
run(slug: string, inputs?: Record<string, unknown>, opts?: {
inputOverrides?: Record<string, Record<string, unknown>>
}): Promise<{ executionId: string; status: "pending" | "running"; runId?: string }>속성
타입
const { executionId } = await client.apps.run("pro-headshot", { photo: photoUrl })
// Add hidden text before the app's prompt, for this run only
await client.apps.run(
"pro-headshot",
{ photo: photoUrl },
{ inputOverrides: { n1: { promptPrefix: "Studio portrait of" } } },
)노출된 동영상 URL 노드로 동영상 링크를 받는 앱은 링크를 입력값으로 넣어 실행합니다. 예: client.apps.run("clip-pack", { episode: "https://www.youtube.com/watch?v=..." }). 서버는 첫 노드가 실행되기 전에 게시물 링크를 다운로드합니다. 4분 이상인 YouTube 동영상은 inputOverrides로 지정한 구간만 다운로드됩니다. 그 밖의 웹 링크는 그대로 사용됩니다.
inputOverrides는 고급 옵션입니다. 예를 들어 노드의 앞뒤 텍스트(promptPrefix와 promptSuffix)를 설정할 수 있습니다. 하지만 Webhook 출력 URL, 게시 계정, 스크레이퍼의 대상 같은 출력 노드의 대상은 설정할 수 없습니다. 그런 재정의는 400 locked_field로 거부됩니다.
apps.listRuns(slug, params?)
앱의 내 실행을 한 페이지씩 나열합니다.
listRuns(slug: string, params?: { limit?: number; cursor?: string }): Promise<{ data: AppRun[]; nextCursor?: string | null }>속성
타입
const { data: runs } = await client.apps.listRuns("pro-headshot", { limit: 10 })
for (const run of runs) console.log(run.status, run.outputs)AppRun에는 id, appSlug, executionId, status(pending, running, completed, failed 또는 cancelled), inputs, outputs(각각 { nodeId, type, url?, text? }), startedAt, finishedAt이 있습니다.
apps.getRun(slug, runId)
앱의 실행 하나를 읽습니다.
getRun(slug: string, runId: string): Promise<{ data: AppRun }>속성
타입
const { data: run } = await client.apps.getRun("pro-headshot", runId)apps.resume(slug, runId, opts?)
실패한 실행을 멈춘 지점부터 다시 시도합니다. 앱 페이지의 다시 시도 버튼과 같습니다. 실행이 완료하지 못한 단계만 실행되고, 그 단계만 청구됩니다. 완료한 모든 단계는 결과를 넘겨줍니다. 실패한 UGC 클립은 끝내지 못한 클립만 렌더링합니다.
resume(slug: string, runId: string, opts: { dryRun: true; version?: number }): Promise<{ data: AppRunResumePlan }>
resume(slug: string, runId: string, opts?: { dryRun?: false; version?: number }): Promise<AppRunResumeResult>속성
타입
- 실행 자체의 버전과 입력. 다시 시도는 그 실행이 실행한 앱 버전을, 그 실행이 적용한 입력으로 실행합니다. 자체 입력은 받지 않습니다.
- 시험 실행.
dryRun: true를 쓰면 응답은AppRunResumePlan입니다.runId,continuesExecutionId,appVersion,nodeIds,steps({ nodeId, type, label }, 다시 실행될 단계),estimatedCredits,reusedClips,sufficient,available을 담습니다.estimatedCredits는 앱의 크리에이터 수수료를 포함하며, 크레딧이 없는 환경에서는null입니다.sufficient는 내 잔액과 앱 크레딧으로 다시 시도 비용을 감당할 수 있는지 알려 줍니다.appCreditsAllowance는 앱 크레딧 때문에 막힐 때만 들어 있습니다. 다시 시도하기 전에 계획을 보여 주세요. - 시작된 다시 시도.
dryRun이 없으면 응답은{ executionId, runId, status: "pending", nodeIds, deduped? }입니다.client.executions.get(executionId)로 폴링하세요. 실행의 실행 기록이 다시 시도의 것으로 바뀌므로, 그 뒤에는getRun이 그것을 보여 줍니다. - 다시 시도는 한 번에 하나. 그 다시 시도가 대기 중일 때 다시 호출하면, 그 실행 기록을 알려 주는
AlreadyRunningError가 발생합니다. 정확히 같은 순간에 누른 두 번만 같은 다시 시도에 닿으며,deduped: true로 응답합니다.
거부는 무엇이든 기록되거나 청구되기 전에 일어납니다. code는 AppRunResumeRefusalCode 중 하나입니다.
code | 발생하는 오류 | 경우 |
|---|---|---|
not_found | NotFoundError | 이 앱에 그런 내 실행이 없습니다. |
continuation_not_found | NotFoundError | 실행의 실행 기록이 내 것이 아닙니다. |
validation_error | NodaroError(400) | 실행 id나 본문의 형식이 잘못되었거나, 컴포넌트의 실행입니다. |
app_run_version_unavailable | NodaroError(409) | 실행이 실행한 버전이 없어졌습니다. 실행을 처음부터 다시 시작하세요. |
app_run_version_changed | AppRunVersionChangedError | 앱이 실행이 실행한 것과 다른 버전에 있습니다. 처음부터 다시 시작하거나, version: err.runVersion을 보내세요. |
continuation_workflow_mismatch / continuation_version_mismatch | NodaroError(400) | 실행의 실행 기록이 다른 워크플로나 그 워크플로의 다른 버전을 실행했습니다. 실행을 처음부터 다시 시작하세요. |
continuation_not_failed | NodaroError(409) | 실행이 완료되었거나 중지되었습니다. 처음부터 다시 시작하세요. |
already_running | AlreadyRunningError(409, executionId) | 실행이 아직 진행 중이거나, 그 실행의 다시 시도가 대기 중입니다. executionId를 따라가세요. |
continuation_subset_required | NodaroError(409 또는 400) | 다시 시도할 것이 남아 있지 않거나(409), 앱이 단계를 하나도 실행하지 않습니다(400). |
locked_field | NodaroError(400) | 실행이 적용한 입력이, 앱이 실행하는 사용자에게 설정을 허용하지 않는 필드를 설정합니다. |
preview_review_required | NodaroError(400) | 다시 시도가 검토할 사람이 없는 미리 보기에서 멈추게 됩니다. 앱 페이지에서 다시 시도하세요. |
insufficient_app_credits / insufficient_credits | InsufficientCreditsError | 앱 크레딧이나 잔액으로 다시 시도 비용을 감당할 수 없습니다. code가 어느 쪽인지 알려 줍니다. |
billing_unavailable | NodaroError(503) | 워크스페이스 실행에서 결제 기능을 잠시 사용할 수 없습니다. 잠시 후 다시 시도하세요. |
다른 입력이나 앱의 현재 버전으로 실행하려면, 대신 apps.run으로 실행을 처음부터 다시 시작하세요. 그러면 모든 단계가 다시 실행되고 다시 청구됩니다. 실패한 실행 다시 시도를 참고하세요.
import { AppRunVersionChangedError } from "@nodaro/sdk/errors"
const { data: plan } = await client.apps.resume("pro-headshot", runId, { dryRun: true })
console.log(`${plan.steps.length} step(s) again, about ${plan.estimatedCredits} credits`)
try {
const { executionId } = await client.apps.resume("pro-headshot", runId)
} catch (err) {
if (err instanceof AppRunVersionChangedError && err.runVersion !== undefined) {
// Continue on the run's own version anyway, or start over with apps.run.
await client.apps.resume("pro-headshot", runId, { version: err.runVersion })
}
}apps.deleteRun(slug, runId)
실행을 보관합니다. 실행을 복원하거나 영구 삭제하는 기능은 Nodaro 앱에서만 사용할 수 있으므로, 스크립트가 데이터를 없앨 수는 없습니다.
deleteRun(slug: string, runId: string): Promise<{ success: true; archived: true }>속성
타입
await client.apps.deleteRun("pro-headshot", runId)client.templates
설계상 공개된 템플릿 마켓플레이스입니다. 둘러보고, 템플릿을 전체 워크플로와 함께 읽고, 내 프로젝트에 무료로 복제하세요.
templates.browse(params?)
마켓플레이스를 한 페이지씩 둘러봅니다(GET /v1/templates/browse). 로그인이 필요 없습니다.
browse(params?: BrowseTemplatesParams): Promise<{ data: TemplateBrowseCard[]; nextCursor: string | null }>속성
타입
const page = await client.templates.browse({ sort: "popular", search: "trailer" })공개 작업을 허용하지 않는 배포 환경(outputs.allowPublic: false)에서는 마켓플레이스에 아무것도 나열되지 않습니다: { data: [], nextCursor: null }.
카드의 estimatedCredits는 템플릿의 표시 가격입니다. 가격이 템플릿에 입력되는 녹음의 길이를 따르면 estimatedPerMinuteCredits가 0보다 큽니다. 그러면 가격은 estimatedCredits에 녹음 1분마다 그만큼의 크레딧을 더한 값입니다. 그렇지 않으면 estimatedPerMinuteCredits는 없거나 0입니다. 템플릿의 선택지가 더 비쌀 수 있으면 카드에는 가격 범위의 상한인 maxEstimatedCredits와 maxEstimatedPerMinuteCredits도 있습니다.
경로는 템플릿 페이지의 크레딧 적은 순 정렬인 sort=cheapest도 받습니다. 60분 녹음의 가격이 낮은 순서로 정렬하며, 그 가격은 estimatedCredits에 estimatedPerMinuteCredits의 60배를 더한 값입니다. SDK의 TemplateSort 타입에는 cheapest가 없으므로 client.request()로 보내세요.
templates.get(slug)
공개 템플릿 하나를 전체 워크플로 스냅샷인 snapshotNodes, snapshotEdges, snapshotSettings와 함께 읽습니다(GET /v1/templates/:slug).
get(slug: string): Promise<Template>속성
타입
const template = await client.templates.get("noir-trailer")
console.log(template.snapshotNodes.length)슬러그를 알 수 없거나, 목록에서 제외되었거나, 비활성 상태이면 NotFoundError를 발생시킵니다. 공개 작업을 허용하지 않는 배포 환경에서는 마켓플레이스에만 나열된 다른 사람의 템플릿에도 NotFoundError를 발생시킵니다. 튜토리얼 채널의 템플릿은 계속 응답합니다.
templates.clone(slug, params)
템플릿을 내 프로젝트 중 하나에 새 워크플로로 복사합니다(POST /v1/templates/:slug/clone). 크레딧이 들지 않습니다.
clone(slug: string, params: { projectId: string; name?: string }): Promise<{ workflowId: string; projectId: string }>속성
타입
const { workflowId } = await client.templates.clone("noir-trailer", { projectId })
await client.workflows.run(workflowId)공개 작업을 허용하지 않는 배포 환경에서는 다른 사람의 마켓플레이스 템플릿이 404 not_found로 응답합니다. 내 템플릿과 튜토리얼 템플릿은 전과 같이 복제됩니다.
client.tutorials
tutorials.list()
모든 튜토리얼 카테고리를 그 튜토리얼 동영상, 튜토리얼 워크플로와 함께 나열합니다(GET /v1/tutorials). 공개되어 있으며 읽기 전용입니다.
list(): Promise<{ categories: TutorialCategory[] }>const { categories } = await client.tutorials.list()
for (const category of categories) {
console.log(category.name, category.videos.length, category.flows.length)
}각 카테고리에는 id, name, slug, sortOrder, videos, flows가 있습니다. 동영상에는 title, videoUrl, thumbnailUrl이 있습니다. 플로는 튜토리얼로 표시된 템플릿으로, title, complexity, estimatedCredits, 사용하는 노드 유형과 모델, 그리고 templates.get()과 templates.clone()에 전달할 수 있는 slug가 있습니다.
자주 묻는 질문
코드에서 Nodaro 앱을 실행하려면 어떻게 하나요?
앱의 슬러그와, 키가 앱의 입력 필드와 일치하는 inputs 객체를 담아 client.apps.run을 호출하세요. executionId가 반환되므로, 결과는 client.executions.get(executionId)를 폴링해 받으세요.
앱이 기대하는 입력은 어떻게 알 수 있나요?
client.apps.get(slug)을 호출하세요. inputSchema에는 최종 사용자가 채우는 필드가, outputs에는 앱이 반환하는 것이 나열됩니다.
템플릿을 복제하면 크레딧이 드나요?
아니요. client.templates.clone은 템플릿을 내 프로젝트 중 하나에 무료로 복사합니다. 비용은 새 워크플로를 실행할 때만 듭니다.
코드에서 실패한 앱 실행을 다시 시도하려면 어떻게 하나요?
client.apps.resume(slug, runId, { dryRun: true })를 호출해 단계와 가격을 확인한 다음, dryRun 없이 다시 호출하세요. 실행이 완료하지 못한 단계만 실행되고, 그 단계만 청구됩니다.
inputOverrides로 앱이 결과를 보내는 곳을 바꿀 수 있나요?
아니요. 재정의로는 Webhook 출력 URL이나 게시 계정 같은 대상을 설정할 수 없습니다. 이런 실행은 400 locked_field로 거부됩니다.
관련 문서
앱(미니앱)
워크플로와 프로젝트
작업과 실행
튜토리얼과 템플릿
최종 업데이트