Title: RequestOptions::fromArray
Published: May 20, 2026

---

# RequestOptions::fromArray( $array )

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-http-dto-requestoptions/fromarray/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-http-dto-requestoptions/fromarray/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-http-dto-requestoptions/fromarray/?output_format=md#changelog)

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

{@inheritDoc}

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

    ```php
    public static function fromArray(array $array): self
    {
        $instance = new self();
        if (isset($array[self::KEY_TIMEOUT])) {
            $instance->setTimeout((float) $array[self::KEY_TIMEOUT]);
        }
        if (isset($array[self::KEY_CONNECT_TIMEOUT])) {
            $instance->setConnectTimeout((float) $array[self::KEY_CONNECT_TIMEOUT]);
        }
        if (isset($array[self::KEY_MAX_REDIRECTS])) {
            $instance->setMaxRedirects((int) $array[self::KEY_MAX_REDIRECTS]);
        }
        return $instance;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/providers/http/dto/requestoptions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/src/Providers/Http/DTO/RequestOptions.php#L165)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/src/Providers/Http/DTO/RequestOptions.php#L165-L178)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-http-dto-requestoptions/fromarray/?output_format=md#related)󠁿

| Used by | Description | 
| [Request::fromArray()](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-http-dto-request/fromarray/)`wp-includes/php-ai-client/src/Providers/Http/DTO/Request.php` |

{@inheritDoc}

  | 
| [WP_AI_Client_Prompt_Builder::__construct()](https://developer.wordpress.org/reference/classes/wp_ai_client_prompt_builder/__construct/)`wp-includes/ai-client/class-wp-ai-client-prompt-builder.php` |

Constructor.

  |

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

| Version | Description | 
| [0.2.0](https://developer.wordpress.org/reference/since/0.2.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-providers-http-dto-requestoptions%2Ffromarray%2F)
before being able to contribute a note or feedback.