Sign up (with export icon)

AIQuickActionCustomActionDefinition

Api-typedef icontypedef

A custom AI quick action definition.

The action needs a prompt source, provided in one of three ways:

  • an inline prompt string - sent as the prompt,
  • a context reference - the referenced context drives the action (for example through a prompt it contains),
  • both - the inline prompt is used and the context is attached as additional reference material (for example a file).

The model property is optional. If not specified, the default model (from the ai.models.defaultModelId configuration or the first available model) is used.

{
	id: 'add-quote-from-famous-person',
	label: 'Add a quote from a famous person',
	prompt: 'Add a quote from a known person, which would make sense in the context of the selected text.',
	type: 'action',
	model: 'claude-4-6-sonnet'
}
Copy code

The same action using a context reference instead of an inline prompt:

{
	id: 'add-quote-from-famous-person',
	label: 'Add a quote from a famous person',
	context: { id: 'my-context', promptId: 'add-quote' },
	type: 'action',
	model: 'claude-4-6-sonnet'
}
Copy code

An inline prompt combined with a context that attaches a single file as reference material:

{
	id: 'add-quote-from-famous-person',
	label: 'Add a quote from a famous person',
	prompt: 'Add a quote from a known person, which would make sense in the context of the selected text.',
	context: { id: 'my-context', fileId: 'famous-quotes' },
	type: 'action',
	model: 'claude-4-6-sonnet'
}
Copy code

Properties

  • Chevron-right icon

    context : AIContextRef | undefined
    readonly

    A context reference attached to the action.

    When no inline prompt is provided, the referenced context drives the action (a whole context or a promptId reference). When combined with an inline prompt, it is attached as additional reference material (for example a single file).

    Experimental: This is a production-ready API but may change in minor releases without the standard deprecation policy. Check the changelog for migration guidance.

  • Chevron-right icon

    prompt : string | undefined
    readonly

    The prompt to be sent to the AI model when the action is executed.

    At least one prompt source is required: an inline prompt, a context that carries a prompt (a whole context or a promptId reference), or both. A context that references only a single file (fileId) cannot drive the action on its own and must be combined with an inline prompt.

  • type : 'action'