One Article to Get Coze Connected to the OpenAI Hub API
This tutorial helps you quickly connect Coze to the large model interface of OpenAI Hub, using Coze’s plugin system to call https://api.openai-hub.com/v1, achieving seamless integration with GPT, Claude, and other models.
1. Register & Create an Agent
Log in to the Coze official website and register an account. After entering the dashboard:
- Click "Create Bot / Agent" on the left.
- Fill in a name, such as “AI Content Assistant.”
- Write any description, for example, “Help me generate copy and answer questions.”
- You can choose any placeholder model for now; we’ll replace it with the OpenAI Hub interface later.
After finishing, click save. No need to publish yet.
2. Get an OpenAI Hub API Key
Go to the OpenAI Hub Console to get your key:
- Register and log in to the console.
- Find API Key Management in the sidebar.
- Create a new key, for example
sk-your-api-key.
This key is your unique credential; don’t post it in any group chats or public Git repositories.
3. Create an API Plugin in Coze
Open Plugin on the left and create a new custom plugin.
Configuration details:
-
Plugin Name: OpenAI Hub Relay (any name is fine)
-
Type: HTTP API
-
Request Method: POST
-
API Address (Base URL):
https://api.openai-hub.com/v1/chat/completions -
Authentication: Add the following to the Header:
{ "Authorization": "Bearer sk-your-api-key", "Content-Type": "application/json" } -
Input Parameter Definition:
[ { "name": "prompt", "type": "string", "required": true, "description": "User input content" } ] -
Request Body Mapping (Body):
{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "{{input.prompt}}" } ] }
⚠️ Note:
When entering the URL in Coze, don’t add extra / at the end, or it may show “Invalid request path.” Also, make sure there’s a space after Bearer in the Header.
4. Test if the Plugin Works
After configuration, click “Test” on the plugin page. Enter:
prompt = Write me a sentence to inspire myself to study
If everything is fine, the model’s generated result will be returned. If it shows a timeout, it means the direct connection was blocked — make sure your address is:
https://api.openai-hub.com/v1/chat/completions
This is a relay address that works directly from mainland China.
5. Attach the Plugin to the Agent
Go back to the Bot editing page, click “Add Tool / Plugin,” and attach the plugin you just created.
In the conversation flow, set up a trigger rule such as: when the Bot hears the keyword “Ask AI,” it calls the plugin.
After setting this up, click “Debug” in the bottom right corner to see whether the Bot’s response goes through the OpenAI Hub interface.
6. Advanced: Support Multiple Models
If you want one plugin to support multiple models — such as GPT-4, Claude 3, or Gemini 1.5 — you can modify the Body as follows:
{
"model": "{{input.model|default('gpt-4o-mini')}}",
"messages": [
{ "role": "user", "content": "{{input.prompt}}" }
]
}
Then add a model to the input parameter list with type string. By doing this, you can dynamically specify which model to use when calling the plugin.
7. Call It in Workflow (Optional)
If you use Workflow in Coze for multi-step processing, like “Ask → Rephrase → Output Result,” you can add this custom plugin at a node to handle Q&A or content generation. Think of it like building with LEGO blocks.
Next Step to Try
You can add a simple FAQ knowledge base in Coze’s Knowledge module and let the plugin generate extended content. That way, your Bot can both retrieve knowledge and create output — making it truly “alive.”
