Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paths/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
schema:
$ref: "../schemas/responses/generationerrorresponse.yaml#/GenerationErrorResponse"
description: |
Generate a single image, video or audio asset from a text prompt without
rendering a full edit. Submit a prompt-bearing asset; the response is
Generate a single image, video or audio asset from a prompt or, for some models, a source file, without
rendering a full edit. Submit an asset with a prompt or source file; the response is
immediate when an identical asset has been generated before (results are
cached by prompt, model and options), otherwise the job is queued and can
be polled via the status endpoint.
Expand Down
2 changes: 1 addition & 1 deletion paths/models.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
get:
description: |
List the generation models available for `prompt`-bearing image, video and audio
assets, with the options each accepts. Use `POST /generate/quote` for a credit estimate.
assets generated from a prompt or, for some models, a source file, with the options each accepts. Use `POST /generate/quote` for a credit estimate.

Use this to populate a model picker and render its option fields, rather than
hard coding a model list. A newly launched model appears here without any change
Expand Down
11 changes: 9 additions & 2 deletions schemas/generationasset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
GenerationAsset:
description: An image, video or audio asset to generate from a text prompt.
description: >-
An asset to generate, from a text `prompt` or, for models that take one, a source
`src`.
type: object
properties:
type:
Expand All @@ -16,6 +18,12 @@
maxLength: 4000
pattern: '\S'
example: A lighthouse on a rocky coast at sunset, cinematic lighting
src:
description: >-
The source file for models that take one instead of a prompt, such as
`shotstack-music-analysis`. A public HTTPS URL.
type: string
format: uri
model:
description: >-
The generation model. Defaults to `nano-banana-2` for images,
Expand All @@ -37,4 +45,3 @@
additionalProperties: false
required:
- type
- prompt
2 changes: 1 addition & 1 deletion schemas/generationmodel.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GenerationModel:
description: >-
A generation model available to `prompt`-bearing image, video and audio assets,
A generation model available to image, video and audio assets generated from a prompt or, for some models, a source file,
with the options it accepts. Use `POST /generate/quote` for a credit estimate. Render a model picker and its
option fields from this rather than hard coding a model list, so a newly launched
model is available without a client release.
Expand Down
1 change: 1 addition & 0 deletions scripts/fix-discriminator.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ function addSrcOrPromptRefine(code, zPrefix) {
'imageassetImageAssetSchema',
'videoassetVideoAssetSchema',
'audioassetAudioAssetSchema',
'generationassetGenerationAssetSchema',
];
const strictMarker = '.strict()';
const superRefine = strictMarker + '.superRefine((data, ctx) => {\n' +
Expand Down
6 changes: 6 additions & 0 deletions tests/smoke.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ async function run() {
assert.strictEqual(zodCjs.generationmodelpricingGenerationModelPricingSchema, undefined);
});

check("Generation assets accept a source file or a prompt", () => {
const analysis = { body: { asset: { type: "audio", model: "shotstack-music-analysis", src: "https://example.com/a.mp3" } } };
assert(zodCjs.postGenerateRequest.safeParse(analysis).success, "a src-input asset parses");
assert(!zodCjs.postGenerateRequest.safeParse({ body: { asset: { type: "audio" } } }).success, "an asset needs src or prompt");
});

check("Parse valid rich-text asset", () => {
const result = zodCjs.richTextAssetSchema.parse({
type: "rich-text",
Expand Down
Loading