diff --git a/src/Form/AIImageAPI.php b/src/Form/AIImageAPI.php
index 6d84572..37b57f4 100644
--- a/src/Form/AIImageAPI.php
+++ b/src/Form/AIImageAPI.php
@@ -67,6 +67,7 @@ class AIImageAPI extends ConfigFormBase
 
     // Define a textfield for the API Key.
     $form['api_settings']['apikey']=[
+      '#maxlength' => 256,
       '#required'=> true,
       '#type'=>'textfield',
       '#title' => $this->t('API Key'),
