Title: _wp_connectors_register_default_ai_providers
Published: May 20, 2026

---

# _wp_connectors_register_default_ai_providers( WP_Connector_Registry $registry )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Registers connectors for the built-in AI providers.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#parameters)󠁿

 `$registry`[WP_Connector_Registry](https://developer.wordpress.org/reference/classes/wp_connector_registry/)
required

The connector registry instance.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#source)󠁿

    ```php
    function _wp_connectors_register_default_ai_providers( WP_Connector_Registry $registry ): void {
    	// Built-in connectors.
    	$defaults = array(
    		'anthropic' => array(
    			'name'           => 'Anthropic',
    			'description'    => __( 'Text generation with Claude.' ),
    			'type'           => 'ai_provider',
    			'plugin'         => array(
    				'file' => 'ai-provider-for-anthropic/plugin.php',
    			),
    			'authentication' => array(
    				'method'          => 'api_key',
    				'credentials_url' => 'https://platform.claude.com/settings/keys',
    			),
    		),
    		'google'    => array(
    			'name'           => 'Google',
    			'description'    => __( 'Text and image generation with Gemini and Imagen.' ),
    			'type'           => 'ai_provider',
    			'plugin'         => array(
    				'file' => 'ai-provider-for-google/plugin.php',
    			),
    			'authentication' => array(
    				'method'          => 'api_key',
    				'credentials_url' => 'https://aistudio.google.com/api-keys',
    			),
    		),
    		'openai'    => array(
    			'name'           => 'OpenAI',
    			'description'    => __( 'Text and image generation with GPT and Dall-E.' ),
    			'type'           => 'ai_provider',
    			'plugin'         => array(
    				'file' => 'ai-provider-for-openai/plugin.php',
    			),
    			'authentication' => array(
    				'method'          => 'api_key',
    				'credentials_url' => 'https://platform.openai.com/api-keys',
    			),
    		),
    	);

    	// Merge AI Client registry data on top of defaults.
    	// Registry values (from provider plugins) take precedence over hardcoded fallbacks.
    	$ai_registry = AiClient::defaultRegistry();

    	foreach ( array_filter( $ai_registry->getRegisteredProviderIds() ) as $connector_id ) {
    		$provider_class_name = $ai_registry->getProviderClassName( $connector_id );
    		$provider_metadata   = $provider_class_name::metadata();

    		$auth_method = $provider_metadata->getAuthenticationMethod();
    		$is_api_key  = null !== $auth_method && $auth_method->isApiKey();

    		if ( $is_api_key ) {
    			$credentials_url = $provider_metadata->getCredentialsUrl();
    			$authentication  = array(
    				'method' => 'api_key',
    			);
    			if ( $credentials_url ) {
    				$authentication['credentials_url'] = $credentials_url;
    			}
    		} else {
    			$authentication = array( 'method' => 'none' );
    		}

    		$name        = $provider_metadata->getName();
    		$description = $provider_metadata->getDescription();
    		$logo_url    = $provider_metadata->getLogoPath()
    			? _wp_connectors_resolve_ai_provider_logo_url( $provider_metadata->getLogoPath() )
    			: null;

    		if ( isset( $defaults[ $connector_id ] ) ) {
    			// Override fields with non-empty registry values.
    			if ( $name ) {
    				$defaults[ $connector_id ]['name'] = $name;
    			}
    			if ( $description ) {
    				$defaults[ $connector_id ]['description'] = $description;
    			}
    			if ( $logo_url ) {
    				$defaults[ $connector_id ]['logo_url'] = $logo_url;
    			}
    			// Always update auth method; keep existing credentials_url as fallback.
    			$defaults[ $connector_id ]['authentication']['method'] = $authentication['method'];
    			if ( ! empty( $authentication['credentials_url'] ) ) {
    				$defaults[ $connector_id ]['authentication']['credentials_url'] = $authentication['credentials_url'];
    			}
    		} else {
    			$defaults[ $connector_id ] = array(
    				'name'           => $name ? $name : ucwords( $connector_id ),
    				'description'    => $description ? $description : '',
    				'type'           => 'ai_provider',
    				'authentication' => $authentication,
    			);
    			if ( $logo_url ) {
    				$defaults[ $connector_id ]['logo_url'] = $logo_url;
    			}
    		}
    	}

    	// Register all default connectors directly on the registry.
    	foreach ( $defaults as $id => $args ) {
    		if ( 'api_key' === $args['authentication']['method'] ) {
    			$sanitized_id = str_replace( '-', '_', $id );

    			$args['authentication']['setting_name'] = "connectors_ai_{$sanitized_id}_api_key";

    			// All AI providers use the {CONSTANT_CASE_ID}_API_KEY naming convention.
    			$constant_case_key = strtoupper( (string) preg_replace( '/([a-z])([A-Z])/', '$1_$2', $sanitized_id ) ) . '_API_KEY';

    			$args['authentication']['constant_name'] = $constant_case_key;
    			$args['authentication']['env_var_name']  = $constant_case_key;
    		}

    		$args['plugin']['is_active'] = static function () use ( $ai_registry, $id ): bool {
    			try {
    				return $ai_registry->hasProvider( $id );
    			} catch ( Exception $e ) {
    				return false;
    			}
    		};

    		$registry->register( $id, $args );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/connectors.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/connectors.php#L283)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/connectors.php#L283-L406)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#related)󠁿

| Uses | Description | 
| [AiClient::defaultRegistry()](https://developer.wordpress.org/reference/classes/wordpress-aiclient-aiclient/defaultregistry/)`wp-includes/php-ai-client/src/AiClient.php` |

Gets the default provider registry instance.

  | 
| [_wp_connectors_resolve_ai_provider_logo_url()](https://developer.wordpress.org/reference/functions/_wp_connectors_resolve_ai_provider_logo_url/)`wp-includes/connectors.php` |

Resolves an AI provider logo file path to a URL.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#)

| Used by | Description | 
| [_wp_connectors_init()](https://developer.wordpress.org/reference/functions/_wp_connectors_init/)`wp-includes/connectors.php` |

Initializes the connector registry with default connectors and fires the registration action.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_connectors_register_default_ai_providers/?output_format=md#changelog)󠁿

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

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_connectors_register_default_ai_providers%2F)
before being able to contribute a note or feedback.