Connect an AI provider
Choose OpenAI, DeepSeek or an OpenAI-compatible endpoint, enter the API key and model, save and test the connection, then monitor tokens, cost and recent AI calls.
What is the AI Provider for?#
Every AI feature in LDPage (AI page generation, the AI Agent in the editor, content rewriting, SEO…) calls one AI provider shared by all customers. You set it up once in Admin › Settings › AI Provider (Integrations group). Customers never see the API key; each time a customer uses AI, AI credits in their plan are deducted by tokens (1 credit ≈ 1.000 tokens).
1. Choose the provider, endpoint and API key#
- 1
Open the account menu › SaaS admin › Settings and choose AI Provider in the Integrations group on the left.
- 2
In the Connect AI (Kết nối AI) card, choose the Provider: OpenAI, DeepSeek or OpenAI-compatible (custom). OpenAI and DeepSeek prefill the Endpoint (https://api.openai.com/v1 or https://api.deepseek.com).
- 3
OpenAI-compatible is for servers with an OpenAI-style API such as Ollama, vLLM, OpenRouter…: type the Endpoint (API base URL) yourself and leave the API key empty if the endpoint needs none.
- 4
Enter the API key. It is stored encrypted on your server; after saving the field shows •••••••• (saved — type to replace), and you leave it empty to keep the old key. The Get API key link opens the selected provider's key page.
- 5
If you switch to a provider different from the saved one, the old key cannot be used: the form says the saved key belongs to the previous provider and asks for a new one.
2. Choose models, unit prices and timeout#
- 1
Text model (Model văn bản): type a model name or click a suggestion chip below (OpenAI: gpt-4o-mini, gpt-4o, gpt-4.1-mini, gpt-4.1; DeepSeek: deepseek-flash, deepseek-v4-pro). This model handles most tasks.
- 2
AI Agent model (optional): a stronger model for heavy AI Agent work such as code mode or rewriting many sections. Empty = use the text model; light tasks still use the text model to stay fast and cheap.
- 3
Unit price (USD/1M tokens): enter Input and Output prices from your provider's price list so LDPage can estimate cost (the AI Agent shows an estimate per run, the Overview page shows AI cost this month). Empty = no cost estimate.
- 4
Timeout: the maximum seconds to wait for one AI call (5–600 seconds, default 120). Increase it if the model is slow or long pages time out.
3. Save, then test the connection#
- 1
Click Save configuration (Lưu cấu hình) at the bottom of the Connect AI card.
- 2
Click Test connection (Kiểm tra kết nối). LDPage sends a small request to the provider using the SAVED configuration, so save before testing; otherwise the result reflects the old settings.
- 3
The Connection status card on the right shows Configured, Not configured or Connection error with the error message; the sub-line shows the provider, configuration source (database or environment variables) and model. Response time and Last checked update after each test.
- 4
Once connected, generate a page with AI to make sure everything works end to end.
4. Monitor usage and cost#
- 1
The AI usage card totals Prompt tokens, Completion tokens and Estimated cost across the whole system. It is for operational monitoring only; per-customer limits live in plan limits.
- 2
The Recent activity table lists the latest AI calls: Time, Operation (e.g. template_agent.plan, template_agent.copy_section), Model, Tokens (in/out) and Latency.
- 3
Estimated cost only appears once unit prices are entered; if it always shows $0.0000, check the Input and Output fields.
- 4
To see which customers cost the most, use the highest-AI-cost customers table in Admin › Overview; to cap usage, adjust AI runs/month and AI credits/month in Plans.
5. Configure AI with environment variables#
When the server sets AI_BASE_URL and AI_TEXT_MODEL (with AI_API_KEY, and optionally AI_PROVIDER, AI_AGENT_MODEL, AI_TIMEOUT_MS), the environment takes priority over the screen: the AI Provider page notes that the provider is configured via environment variables and the connection status shows source: environment variables. To manage it from the screen, leave AI_BASE_URL and AI_TEXT_MODEL empty in .env and restart the API.
Troubleshooting#
- 1
Test says the AI provider is not configured: you have not clicked Save configuration, or Endpoint/Model is empty.
- 2
Authentication error: the API key is wrong, expired or belongs to another provider; enter it again and save.
- 3
Timeout error: raise the Timeout, check the server can reach the Endpoint over the Internet, or choose a faster model.
- 4
Changes on screen have no effect: check AI_BASE_URL/AI_TEXT_MODEL on the server (environment wins).
- 5
A customer runs out of AI credits: check the AI credits/month of their plan or assign a higher plan in Admin › Customers.