diff --git a/paths/generate.yaml b/paths/generate.yaml index 6883559..3205c12 100644 --- a/paths/generate.yaml +++ b/paths/generate.yaml @@ -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. diff --git a/paths/models.yaml b/paths/models.yaml index f0eda11..871f864 100644 --- a/paths/models.yaml +++ b/paths/models.yaml @@ -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 diff --git a/schemas/generationasset.yaml b/schemas/generationasset.yaml index 6f70b78..0516a0e 100644 --- a/schemas/generationasset.yaml +++ b/schemas/generationasset.yaml @@ -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: @@ -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, @@ -37,4 +45,3 @@ additionalProperties: false required: - type - - prompt diff --git a/schemas/generationmodel.yaml b/schemas/generationmodel.yaml index 1187968..03eecab 100644 --- a/schemas/generationmodel.yaml +++ b/schemas/generationmodel.yaml @@ -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. diff --git a/scripts/fix-discriminator.cjs b/scripts/fix-discriminator.cjs index 82edcf4..6128b57 100644 --- a/scripts/fix-discriminator.cjs +++ b/scripts/fix-discriminator.cjs @@ -366,6 +366,7 @@ function addSrcOrPromptRefine(code, zPrefix) { 'imageassetImageAssetSchema', 'videoassetVideoAssetSchema', 'audioassetAudioAssetSchema', + 'generationassetGenerationAssetSchema', ]; const strictMarker = '.strict()'; const superRefine = strictMarker + '.superRefine((data, ctx) => {\n' + diff --git a/tests/smoke.cjs b/tests/smoke.cjs index 82b2e5e..811186d 100644 --- a/tests/smoke.cjs +++ b/tests/smoke.cjs @@ -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",