Title: WebSearch
Published: May 20, 2026

---

# class WebSearch {}

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#description)
 * [Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#methods)
 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#wp--skip-link--target)

Represents web search configuration for AI models.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#description)󠁿

This DTO defines constraints for web searches that AI models can perform, including
allowed and disallowed domains.

## 󠀁[Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#methods)󠁿

| Name | Description | 
| [WebSearch::__construct](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/__construct/) | Constructor. | 
| [WebSearch::fromArray](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/fromarray/) | {@inheritDoc} | 
| [WebSearch::getAllowedDomains](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/getalloweddomains/) | Gets the allowed domains. | 
| [WebSearch::getDisallowedDomains](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/getdisalloweddomains/) | Gets the disallowed domains. | 
| [WebSearch::getJsonSchema](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/getjsonschema/) | {@inheritDoc} | 
| [WebSearch::toArray](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/toarray/) | {@inheritDoc} |

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#source)󠁿

    ```php
    class WebSearch extends AbstractDataTransferObject
    {
        public const KEY_ALLOWED_DOMAINS = 'allowedDomains';
        public const KEY_DISALLOWED_DOMAINS = 'disallowedDomains';
        /**
         * @var string[] List of domains that are allowed for web search.
         */
        private array $allowedDomains;
        /**
         * @var string[] List of domains that are disallowed for web search.
         */
        private array $disallowedDomains;
        /**
         * Constructor.
         *
         * @since 0.1.0
         *
         * @param string[] $allowedDomains List of domains that are allowed for web search.
         * @param string[] $disallowedDomains List of domains that are disallowed for web search.
         */
        public function __construct(array $allowedDomains = [], array $disallowedDomains = [])
        {
            $this->allowedDomains = $allowedDomains;
            $this->disallowedDomains = $disallowedDomains;
        }
        /**
         * Gets the allowed domains.
         *
         * @since 0.1.0
         *
         * @return string[] The allowed domains.
         */
        public function getAllowedDomains(): array
        {
            return $this->allowedDomains;
        }
        /**
         * Gets the disallowed domains.
         *
         * @since 0.1.0
         *
         * @return string[] The disallowed domains.
         */
        public function getDisallowedDomains(): array
        {
            return $this->disallowedDomains;
        }
        /**
         * {@inheritDoc}
         *
         * @since 0.1.0
         */
        public static function getJsonSchema(): array
        {
            return ['type' => 'object', 'properties' => [self::KEY_ALLOWED_DOMAINS => ['type' => 'array', 'items' => ['type' => 'string'], 'description' => 'List of domains that are allowed for web search.'], self::KEY_DISALLOWED_DOMAINS => ['type' => 'array', 'items' => ['type' => 'string'], 'description' => 'List of domains that are disallowed for web search.']], 'required' => []];
        }
        /**
         * {@inheritDoc}
         *
         * @since 0.1.0
         *
         * @return WebSearchArrayShape
         */
        public function toArray(): array
        {
            return [self::KEY_ALLOWED_DOMAINS => $this->allowedDomains, self::KEY_DISALLOWED_DOMAINS => $this->disallowedDomains];
        }
        /**
         * {@inheritDoc}
         *
         * @since 0.1.0
         */
        public static function fromArray(array $array): self
        {
            return new self($array[self::KEY_ALLOWED_DOMAINS] ?? [], $array[self::KEY_DISALLOWED_DOMAINS] ?? []);
        }
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/tools/dto/websearch.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/src/Tools/DTO/WebSearch.php#L19)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/src/Tools/DTO/WebSearch.php#L19-L95)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-tools-dto-websearch/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.1.0](https://developer.wordpress.org/reference/since/0.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclient-tools-dto-websearch%2F)
before being able to contribute a note or feedback.