Sanity Library Reference Docs
    Preparing search index...

    Interface GenerateSettings

    Settings for one-shot generation requests via contentAgent.prompt().

    Extends BaseAgentSettings with an additional instructions field for providing custom system-level instructions.

    const { text } = await contentAgent.prompt(
    {
    application: { key: 'projectId.datasetName' },
    config: { capabilities: { read: true, write: false } },
    instructions: 'Be concise',
    },
    { message: 'List my 5 most recent posts' },
    )
    interface GenerateSettings {
        application?: {
            bundleVersion?: string;
            intentBaseUrl?: string;
            key?: string;
            name?: string;
            resource?: { id?: string; type?: "dataset" };
            schemaDescriptorId?: string;
            title?: string;
        };
        config?: {
            capabilities?: {
                features?: { webSearch?: boolean };
                read?: boolean | { preset: "minimal" | "standard" };
                write?: boolean | { preset: "minimal" | "standard" };
            };
            filter?: { read?: string; write?: string };
            instruction?: string;
            perspectives?: { read?: string[]; write?: string };
            userMessageContext?: { [key: string]: string };
        };
        format?: "markdown"
        | "directives";
        instructions?: string;
    }

    Hierarchy

    • BaseAgentSettings
      • GenerateSettings
    Index

    Properties

    application?: {
        bundleVersion?: string;
        intentBaseUrl?: string;
        key?: string;
        name?: string;
        resource?: { id?: string; type?: "dataset" };
        schemaDescriptorId?: string;
        title?: string;
    }

    Target Sanity application configuration.

    Type declaration

    • OptionalbundleVersion?: string

      Bundle version

    • OptionalintentBaseUrl?: string

      Format: uri

      Base URL for the Sanity Studio

      https://your-studio.sanity.studio
      
    • Optionalkey?: string

      Application key in format "projectId.datasetName"

      abc123.production
      
    • Optionalname?: string

      Application name

    • Optionalresource?: { id?: string; type?: "dataset" }
      • Optionalid?: string

        Resource ID in format "projectId.datasetName"

        abc123.production
        
      • Optionaltype?: "dataset"

        Resource type

    • OptionalschemaDescriptorId?: string

      Schema descriptor ID

    • Optionaltitle?: string

      Application title

    config?: {
        capabilities?: {
            features?: { webSearch?: boolean };
            read?: boolean | { preset: "minimal" | "standard" };
            write?: boolean | { preset: "minimal" | "standard" };
        };
        filter?: { read?: string; write?: string };
        instruction?: string;
        perspectives?: { read?: string[]; write?: string };
        userMessageContext?: { [key: string]: string };
    }

    Agent configuration for controlling behavior, capabilities, and document access.

    Type declaration

    • Optionalcapabilities?: {
          features?: { webSearch?: boolean };
          read?: boolean | { preset: "minimal" | "standard" };
          write?: boolean | { preset: "minimal" | "standard" };
      }
      • Optionalfeatures?: { webSearch?: boolean }
        • OptionalwebSearch?: boolean

          Override web search availability. By default, web search is enabled when read capability is 'standard'.

      • Optionalread?: boolean | { preset: "minimal" | "standard" }
      • Optionalwrite?: boolean | { preset: "minimal" | "standard" }
    • Optionalfilter?: { read?: string; write?: string }
      • Optionalread?: string

        GROQ boolean expression for document visibility. Documents matching this filter are visible to the agent.

        _type in ['post', 'author']
        
      • Optionalwrite?: string

        GROQ boolean expression for mutation permissions. Documents matching this filter can be mutated.

        _type == 'post'
        
    • Optionalinstruction?: string

      Custom instruction string to include in the system prompt

      You are a helpful content assistant.
      
    • Optionalperspectives?: { read?: string[]; write?: string }
      • Optionalread?: string[]

        Allowed read perspectives. When set, query tools can only use these perspectives. If the agent tries to use a disallowed perspective, the request is rejected with an error.

        [
        "drafts",
        "published"
        ]
      • Optionalwrite?: string

        The write perspective. When set, new documents are created in this perspective and mutations are restricted to documents whose ID matches it.

        drafts
        
    • OptionaluserMessageContext?: { [key: string]: string }

      Key-value pairs appended to each user message as XML tags. Each key becomes an XML tag with the value as content. Example: { "slack-channel": "#marketing" } renders as #marketing

      {
      * "slack-channel": "#marketing",
      * "user-role": "editor"
      * }
    format?: "markdown" | "directives"

    Controls how directives in the response are formatted.

    • markdown (default): Directives are resolved server-side into standard markdown.
    • directives: Raw directive syntax is preserved for clients that render custom UI.
    'markdown'
    
    instructions?: string

    Custom instructions for the agent.