Outputs
Outputs describe the desired output format / structure (e.g.
"JSON", "Markdown bullet list") that prompts can
reference. Outputs are non-versioned. Like tones, they have no
dedicated visibility endpoint - pass isPublic through
update().
list
client.outputs.list(params?: ListParams): Promise<Page<OutputSummary>>
const page = await client.outputs.list({ scope: "public", pageSize: 12 });
return {
total: page.total,
items: page.items.map((o) => ({ id: o.id, label: o.label, tags: o.tags })),
};
listAll
client.outputs.listAll(params?: ListParams): AsyncIterable<OutputSummary>
const labels = [];
for await (const output of client.outputs.listAll({ scope: "public", pageSize: 12 })) {
labels.push(output.label);
if (labels.length >= 12) break;
}
return labels;
get
client.outputs.get(id: string): Promise<Output>
const page = await client.outputs.list({ scope: "public", pageSize: 6 });
const first = page.items[0];
if (!first) return { empty: true };
const output = await client.outputs.get(first.id);
return {
id: output.id,
label: output.label,
tags: output.tags,
isPublic: output.isPublic,
isOwner: output.isOwner,
};
create
client.outputs.create(input: OutputCreateInput): Promise<OutputCreateResponse>
const created = await client.outputs.create({
label: `docs-demo-output-${Date.now()}`,
isPublic: false,
tags: ["demo"],
});
await client.outputs.delete(created.id);
return created;
update
client.outputs.update(id: string, input: OutputUpdateInput): Promise<void>
Updates label, tags, or visibility. No versioning.
const created = await client.outputs.create({ label: `docs-demo-${Date.now()}`, isPublic: false });
await client.outputs.update(created.id, {
label: `docs-demo-updated-${Date.now()}`,
tags: ["updated"],
isPublic: true,
});
const detail = await client.outputs.get(created.id);
await client.outputs.delete(created.id);
return { label: detail.label, tags: detail.tags, isPublic: detail.isPublic };
delete
client.outputs.delete(id: string): Promise<void>
const created = await client.outputs.create({ label: `docs-demo-${Date.now()}` });
await client.outputs.delete(created.id);
try {
await client.outputs.get(created.id);
return { deleted: false };
} catch (err) {
if (err instanceof PromptyNotFoundError) return { deleted: true };
throw err;
}
vote
client.outputs.vote(id: string, value: 1 | -1): Promise<void>
const created = await client.outputs.create({ label: `docs-demo-vote-${Date.now()}` });
await client.outputs.vote(created.id, 1);
const detail = await client.outputs.get(created.id);
await client.outputs.delete(created.id);
return { upvotes: detail.upvotes, userVote: detail.userVote };
unvote
client.outputs.unvote(id: string): Promise<void>
const created = await client.outputs.create({ label: `docs-demo-unvote-${Date.now()}` });
await client.outputs.vote(created.id, 1);
await client.outputs.unvote(created.id);
const detail = await client.outputs.get(created.id);
await client.outputs.delete(created.id);
return { upvotes: detail.upvotes, userVote: detail.userVote };
toggleFavorite
client.outputs.toggleFavorite(id: string): Promise<{ favorited: boolean }>
const created = await client.outputs.create({ label: `docs-demo-fav-${Date.now()}` });
const a = await client.outputs.toggleFavorite(created.id);
const b = await client.outputs.toggleFavorite(created.id);
await client.outputs.delete(created.id);
return { firstToggle: a.favorited, secondToggle: b.favorited };