---
title: "Replacing AI Engine’s OpenAI Endpoint with Dify’s OpenAI-Compatible API Endpoint"
description: "### STEP1: Always obtain a backup before updating Save the current openai.php as a file that has already been modified to a working state. For example: save a local copy with a name like openai.php-dify. We recommend taking a full…"
url: "https://bestnetllc.co.jp/en/docs/replacing-ai-engines-openai-endpoint-with-difys-openai-compatible-api-endpoint/"
updated: "2026-06-08"
---

# Replacing AI Engine’s OpenAI Endpoint with Dify’s OpenAI-Compatible API Endpoint

### STEP1: Always obtain a backup before updating

Save the current openai.php as a file that has already been modified to a working state. For example: save a local copy with a name like openai.php-dify.

We recommend taking a full backup by backing up either the entire WordPress installation or the plugins folder, so that you can restore if anything goes wrong.

### STEP2: Update AI Engine

Update AI Engine (Meow Apps) from the "Plugins" section of the WordPress admin screen, or overwrite the new version via SFTP/SSH, etc.

After updating, confirm that the plugin is activated.

### STEP3: Since openai.php will be reset, reapply following these steps

- - **Method A:** Manually apply the differences

Refer to the openai.php-dify file from before the modification (confirmed to work), and add or overwrite the relevant sections in the new openai.php (such as build_url(), build_headers(), etc.).

Note that there may be changes added by the AI Engine update, so be careful not to completely replace it. Only manually reproduce the differences.

- - **Method B:** Use a patch file or Git

Create a patch of the modifications in advance using diff / git.

After updating, apply it as patch < openai.patch, and make the same changes again. This is the most reliable semi-automated method.

- - **openai.php after update**
    - File path: wp-content/plugins/ai-engine/classes/engines/openai.php

This file should have been replaced with the latest version by the update.

### STEP4: Verify that the Dify modifications have been reapplied

Check the source code to confirm that the modified sections (for example: endpoint = 'https://your-DIFY-address/e/xxxxxx' in build_url()) remain correct.

- **Test:**
  1. Enable WordPress debug mode, actually send a chat message, and check debug.log.
  2. If the request destination to Dify is https://your-DIFY-address/e/xxxx/chat/completions, it's a success.

If necessary, readjust the model settings or Bearer Key settings (API Key or filters in the admin screen).

### STEP5: If there are issues, recheck version differences

If the internal specifications have changed due to an AI Engine update, you may need to fine-tune the modified sections.

- Check the official update history (changelog) or file differences. If there are major changes to openai.php, the differences may cause conflicts.
- If it doesn't work well, restore from a previous backup to isolate the cause.

## Summary

- **Backup (save the modified openai.php before updating)**
- **Update AI Engine (from plugin management screen, etc.)**
- **Reapply**
  - Manually insert the differences into openai.php
  - Or apply automatically using a patch file or Git
- **Verify operation (confirm that requests are sent to the Dify endpoint)**
