Setting global block attribute value

You could make use of register_post_field() to add the API key to the post object which you then can retrieve via getEditedPostAttribute() in the editor.
In register_post_field() you can define by yourself via get_callback/update_callback how/where the API key should be saved like post meta or an option.

To update the API key in the editor use the editPost() dispatch function which will invoke your update_callback.