Skip to main content
The nx:genai function calls an external AI media generation provider during the render pipeline and injects the result into a specified layer before After Effects starts compositing. This lets you combine AI-generated content with your AE templates in a single job - no manual steps, no intermediate storage wrangling. The provider is called at render time, so the generated asset is always fresh and unique to each job.

Parameters

provider
string
required
The AI provider to call. Currently supported: fal
key
string
required
API key for the provider. Use a secret reference to avoid embedding credentials directly - e.g. ${secret.FAL_KEY}
model
string
required
The model identifier on the provider’s platform. The exact value depends on which model you want to use - refer to your provider’s model library for available options.
type
string
required
Output type: video or image. Determines how the result is injected into the layer.
layerName
string
required
The footage layer in your After Effects composition where the generated asset will be placed.
data
object
required
Model-specific parameters passed directly to the provider’s API. The shape of this object varies by model - refer to your provider’s documentation for the full list of available fields.

Example

The following example uses FAL.AI to generate a talking-head video of a character speaking a provided script, then injects it into a footage layer:
{
  "type": "function",
  "name": "nx:genai",
  "params": {
    "provider": "fal",
    "key": "${secret.FAL_KEY}",
    "model": "infinitalk/single-text",
    "type": "video",
    "layerName": "var_video",
    "data": {
      "image_url": "https://example.com/character.jpg",
      "text_input": "A Victorian inventor journeys to the distant future, encountering the peaceful Eloi and the subterranean Morlocks.",
      "voice": "Eric",
      "prompt": "A young man with a beard records audio with a microphone. He appears engaged and expressive, suggesting a podcast or voiceover.",
      "num_frames": 721,
      "resolution": "720p",
      "acceleration": "high"
    }
  }
}
The data fields here are specific to the infinitalk/single-text model - a different model would expect a different set of parameters. Always consult the model’s documentation on the provider platform for the exact payload shape.

Adaptive Composition Duration

Since AI-generated videos have variable lengths, use nx:layer-duration-set immediately after nx:genai in your assets array to automatically adjust the layer and composition duration to match the generated output:
{
  "type": "function",
  "name": "nx:layer-duration-set",
  "params": {
    "layerName": "var_video"
  }
}

Storing Your Provider Key as a Secret

Never embed provider API keys directly in a job payload. Store them as Nexrender secrets and reference them with the ${secret.NAME} syntax - see Secrets Management for details.