• Resolved wphr24

    (@wphr24)


    When I copy the OpenAI API key into the dashboard and leave the field, I get the message:

    Failed to update the API key.

    What can I do? Can I store it by hand in the database?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author senols

    (@senols)

    Please try the following steps:

    – Deactivate and then reactivate the plugin to see if that fixes the issue.
    – If the problem persists, you can access your database using a plugin like WP phpMyAdmin. From there, locate the wp_wpaicg table. You can either delete this table so it gets recreated automatically, or insert the required data manually.

    Thread Starter wphr24

    (@wphr24)

    • Deactivate and activate doesn’t change it
    • there is no table wp_wpaicg
    • there are entries in wp_options like wpaicg_provider, wpaicg_ai_model but nothing for the API key. Here are some examples (there are 49 in total):

    If you tell me the option_name I’ll put it in manually.

    Thanks in advance.

    Thread Starter wphr24

    (@wphr24)

    Thanks for your response.

    • deactivate / activate doesn’t fix the issue
    • there is no table named wp_wpaicg
    • in table wp_options are entries with option_name wpaicg_* and _wpaicg_*
    • I found wpaicg_provider (e.g. OpenAI) and wpaicg_ai_model (e.g. gpt-4o-mini)
    • Can’t find an entry named wpaicg_api_key or so

    If you can tell me the correkt option_name I’ll put it in.

    Plugin Author senols

    (@senols)

    so that is the root cause why you are not able to store the api key.

    it seems like for some reason main table (wp_wpaicg) is not created in your db. sometimes this happens when the plugin is installed on multisite network.

    so you need to create that table and insert data (make sure to backup you db before performing below command)

    CREATE TABLEwp_wpaicg` (
    ID mediumint NOT NULL,
    name text COLLATE utf8mb4_unicode_520_ci NOT NULL,
    temperature float NOT NULL,
    max_tokens float NOT NULL,
    top_p float NOT NULL,
    best_of float NOT NULL,
    frequency_penalty float NOT NULL,
    presence_penalty float NOT NULL,
    img_size text COLLATE utf8mb4_unicode_520_ci NOT NULL,
    api_key text COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_language varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_add_img tinyint(1) NOT NULL,
    wpai_add_intro tinyint(1) NOT NULL,
    wpai_add_conclusion tinyint(1) NOT NULL,
    wpai_add_tagline tinyint(1) NOT NULL,
    wpai_add_faq tinyint(1) NOT NULL,
    wpai_add_keywords_bold tinyint(1) NOT NULL,
    wpai_number_of_heading int NOT NULL,
    wpai_modify_headings tinyint(1) NOT NULL,
    wpai_heading_tag varchar(10) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_writing_style varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_writing_tone varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_target_url varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_target_url_cta varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    wpai_cta_pos varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL,
    added_date datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
    modified_date datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;


    — Dumping data for table wp_wpaicg

    INSERT INTO wp_wpaicg (ID, name, temperature, max_tokens, top_p, best_of, frequency_penalty, presence_penalty, img_size, api_key, wpai_language, wpai_add_img, wpai_add_intro, wpai_add_conclusion, wpai_add_tagline, wpai_add_faq, wpai_add_keywords_bold, wpai_number_of_heading, wpai_modify_headings, wpai_heading_tag, wpai_writing_style, wpai_writing_tone, wpai_target_url, wpai_target_url_cta, wpai_cta_pos, added_date, modified_date) VALUES
    (1, ‘wpaicg_settings’, 1, 1500, 0.01, 1, 0.01, 0.01, ‘1024×1024’, ‘sk…’, ‘en’, 1, 0, 0, 0, 0, 0, 3, 0, ‘h2’, ‘infor’, ‘formal’, ”, ”, ‘beg’, ‘2024-02-29 15:44:04’, ‘2024-02-29 15:44:04’);`

    Thread Starter wphr24

    (@wphr24)

    It’s a new WordPress 6.8.1 single site installation only to test AI Power. There was no other plugin installed before.

    When I’m changing other settings, they are stored in wp_options and read next time as well. I can see the changes in the database and the dashboard.

    I created the new table and filled it with the given values. Changing settings changed values in the options table – not in the new one.

    I deleted all %aicg% option_name entries and the new table. Then I deactivated and uninstalled the plugin. After a new installation, there wasn’t the new table but the entries in wp_options were generated … without api_key.

    Any idea? I hope we can figure it out.

    Plugin Author senols

    (@senols)

    pls forget about options table.

    the issue is wp_wpaicg table..

    i didnt understand this part “Changing settings changed values in the options table – not in the new one.”

    what do you mean?

    if you already created that table then you should be able to store the api key now.

    Thread Starter wphr24

    (@wphr24)

    After all the steps including new installation the values are stored in wp_options again. The fields with option_name wpaicg_% where regenerated.

    I mean: When I go to the AI Power Dashboard in WordPress and change values, e.g. Engine from OpenAI to Google, I can see the change in wp_options -> wpaicg_provider changing ist option_value from OpenAI to Google.

    When I put in the API key the same failure rises.

    AI Power doesn’t access the new table. It ignores it. It accesses wp_options. It creates fields in wp_options. It creates fields and stores values in wp_options after reinstall.

    Plugin Author senols

    (@senols)

    yes pls dont explain to me how it works, i am the one who wrote it šŸ™‚

    the point is: master api key is stored in wp_wpaicg table. if that table dont exist then nothing is going to work.

    Thread Starter wphr24

    (@wphr24)

    I tell you how it works here – don’t blame your (potential) customer if there’s a bug in your plugin.

    Here you can see it:

    https://interim24.expert/Screenshot_2025-05-07_214617.png

    https://interim24.expert/Screenshot_2025-05-07_214742.png

    As you can see the table is there. The field has the given dummy value but putting in the real key generates the error and the dummy is still there.

    • This reply was modified 1 year, 1 month ago by wphr24.
    Plugin Author senols

    (@senols)

    i am not blaming you. i am trying to help. but pls forget about options table. it has nothing to do with the issue.

    lets try to troubleshoot.

    can you open “developer tools” in google chrome and try to update the api key again and see if there is any error in the console log or network tab?

    Thread Starter wphr24

    (@wphr24)

    That was the first i did.

    Console: No errors. No warnings.

    Network:
    admin-ajax.php 200 xhr load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2 617 B 275 MS

    stack trace:
    send @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2
    ajax @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2
    (anonymous) @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:5
    (anonymous) @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:5
    (anonymous) @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2
    saveApiKey @ https://interim24.expert/wp-content/plugins/gpt3-ai-content-generator/admin/js/wp-ai-content-generator-admin.js?ver=1.9.18:100
    (anonymous) @ https://interim24.expert/wp-content/plugins/gpt3-ai-content-generator/admin/js/wp-ai-content-generator-admin.js?ver=1.9.18:134
    dispatch @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2
    (anonymous) @ https://interim24.expert/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-dom-ready,wp-hooks&ver=6.8.1:2

    Thread Starter wphr24

    (@wphr24)

    Thanks for your help on the other channel.

    Plugin Author senols

    (@senols)

    from the screenshots, it seems the main table wasn’t created properly during the initial launch likely due to an issue retrieving the table prefix.

    glad it’s resolved now.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘API key not stored’ is closed to new replies.