Connect an AI provider
Set up OpenAI, DeepSeek or a custom API in ChatHub: enter a key, select a model, enable AI, save and test with illustrated steps.
Before you start#
This guide helps admins connect the shared AI provider used by ChatHub’s AI Agent features, including reply suggestions, conversation summaries and automated replies. You will select a provider, enter an API key, choose a model, save and check the connection.
- 1
Use a ChatHub account allowed to access and save Settings.
- 2
Prepare an API key for your chosen provider and confirm the API account can use your intended model. Usage is billed directly by the provider.
- 3
For a custom API, also prepare the base API URL and model ID supplied by that service.
1. Open AI provider settings#
- 1
Open Quản trị → Cài đặt (Administration → Settings) in ChatHub.
- 2
Choose Nhà cung cấp AI (AI provider) on the left, or open /settings?tab=ai on your ChatHub domain.
- 3
Find the AI provider panel at the top. It contains Provider, API key, Model, Enable AI features, and the Save and Test connection buttons.
2. Choose a provider and obtain an API key#
- 1
OpenAI: select OpenAI in Nhà cung cấp (Provider). Follow the OpenAI link below Model to its key management page.
- 2
DeepSeek: select DeepSeek and follow the DeepSeek link below Model to its key management page.
- 3
API tùy chỉnh (Custom API): choose this for a service or gateway supporting the OpenAI-compatible API format. Obtain the key, base URL and model ID from that service.
OpenAI API key page linked by ChatHub ↗
DeepSeek API key page linked by ChatHub ↗
Sign in to your account on the provider’s management page and create or obtain an API key using its instructions. Copy it for the ChatHub form. This guide demonstrates ChatHub configuration; it does not create keys or change provider billing.
3. Enter the key, model and enable AI#
- 1
API key: paste the selected provider’s key for the first setup. If a key is already stored, the field is labeled API key mới (New API key).
- 2
Model: enter the exact model ID your API account can use. Select a suggestion or type directly. Leaving it blank uses the provider default in your installed ChatHub version.
- 3
Check Model again after changing Provider: ChatHub clears the previous selection and shows the newly selected provider’s default suggestion.
- 4
Turn on Bật tính năng AI (Enable AI features) to allow AI calls. To stop AI calls, turn it off and save; the key remains stored.
ChatHub encrypts the stored key and never sends it back to the browser. Configured only means a key exists; it does not confirm that the key is valid, the model works or AI is enabled.
4. Configure a custom API#
- 1
Select API tùy chỉnh (Custom API) to reveal URL API.
- 2
Enter the service’s base URL, including the API version when required. https://api.example.com/v1 is an illustrative format; replace it with your actual service URL.
- 3
Do not append /chat/completions or /models. Do not include the API key, login credentials, query parameters (?...) or fragments (#...) in the URL. Put the key in its separate field.
- 4
Enter the custom service’s API key and Model ID. Do not assume the suggested model exists on every gateway.
- 5
Enable AI, then save and test as described below.
The URL must be valid HTTP or HTTPS. The service must support the endpoints ChatHub uses: /models for connection checks and /chat/completions for AI requests. Use the base URL documented by your provider.
5. Save, then test the connection#
- 1
Review Provider, API key, Model, the AI switch and the custom URL if applicable.
- 2
Select Lưu (Save) and wait for “Đã lưu cấu hình AI.” (AI configuration saved).
- 3
Select Kiểm tra kết nối (Test connection). The button is disabled until a key has been stored.
- 4
Read the result: “Gọi được …, model …, mất …ms.” means the provider responded. Check that the displayed provider and model match what you saved.
If the result also says the model is not in the provider’s returned list, check its ID and account access, correct it, save and retest. Some services do not list all models, so also verify with an actual AI feature.
The test requests a model list rather than sending a conversation for a generated reply. Success does not guarantee every generation feature will work. Next, try an AI feature in a test conversation containing material appropriate to send to your provider.
6. Troubleshooting and next steps#
- 1
“Cần nhập API key.” (API key required): no key exists for initial setup. Enter a key and save.
- 2
“Cần nhập URL API HTTP hoặc HTTPS hợp lệ.” (Valid HTTP/HTTPS API URL required): check the custom API URL, remove query parameters, fragments and login credentials, and use the correct base URL.
- 3
Not configured despite a stored key: verify that a provider is selected, AI is enabled and the settings were saved. Also check the URL for a custom API.
- 4
Provider rejected the request: read the displayed status and error details, then check credentials, permissions or your API account as indicated.
- 5
Cannot connect: check the API address and network access from the server running ChatHub. Opening the management website on your computer does not prove the ChatHub server can reach the API.
- 6
Connection test passes but a feature does not run: check the model and that feature’s own configuration. Connecting a provider is a prerequisite, not a replacement for bot or automation setup.
Tài liệu huấn luyện AI (AI training documents) below the panel is for your shop’s question-and-answer content, not API credentials. You can configure knowledge content and AI features after connecting the provider.