Connect OpenAI
Create an OpenAI API key on the API platform, add prepaid credit, set a budget, connect it to SiteTrellis, test it, and fix common errors.
Last updated:
OpenAI's API is billed separately from ChatGPT: a ChatGPT Plus, Team or similar subscription does not include API credit and cannot be used with SiteTrellis. You need an account on the OpenAI API platform. The steps below describe the platform as of writing; consult OpenAI's own help pages if the screens differ.
Create an account and add credit#
- Go to
platform.openai.comand sign in or sign up. Create or select an organization. - Open Settings > Billing. Add a payment method and purchase prepaid credit (OpenAI's API is generally pay-as-you-go from a prepaid balance). With zero balance, requests fail with a quota error even if the key is valid.
- If you want the balance to refill automatically, enable auto-recharge, but pair it with the limits below.
Create the API key#
- In the platform go to Dashboard > API keys (or Settings > API keys).
- Click Create new secret key. Name it, for example, "SiteTrellis production".
- Prefer a key scoped to a dedicated project. A project lets you restrict which models the key may call and track its usage separately from other work.
- Copy the key right away. It starts with
sk-and is shown only once.
Set spend limits#
Under Settings > Limits (organization or project level) set a monthly budget, and an email alert threshold below it. Project-level budgets and model allow-lists are the best way to cap a key used on a public website. Keep in mind that a hard budget stops requests when reached, which means your chat starts failing until you raise it; combine this with a fallback step on another provider if you want the chat to survive.
Paste it into SiteTrellis#
- Open AI providers in the dashboard and add a key.
- Choose OpenAI, enter a label, paste the key and save.
- Wait for the automatic test to mark the key ok.
- In the agent's model section choose this key and pick a model from the model list in the dashboard.
Some models require your organization to be verified, or are only available at higher usage tiers. If a model in the list returns an access error, choose another model or complete the verification in your OpenAI settings.
Typical errors#
| Message or code | Meaning | Fix |
|---|---|---|
| 401 incorrect API key | Wrong, revoked, or truncated key. | Create a new key, paste carefully, and rotate it in. |
| 403 | The key's project cannot use that model, or your country or organization is not permitted. | Allow the model in the project, or pick another. |
| 404 model not found | The model does not exist for your account or has been retired. | Choose another model from the dashboard list. |
| 429 "You exceeded your current quota" | No credit left, or a project budget was reached. | Add credit or raise the budget in Settings, then Test. |
| 429 rate limit reached | Too many requests or tokens per minute for your tier. | Slow down, wait for the tier to grow, or add a fallback step. |
| 500, 502, 503 | OpenAI side issue. | Temporary. A fallback step covers it. |
Note that OpenAI uses HTTP 429 for both "out of money" and "too fast". The error text tells them apart.
Data handling#
Visitor messages and your prompt are sent to OpenAI under your organization's terms. OpenAI documents how API data is retained and whether it is used for training, and offers data controls for eligible organizations. Read the current API data usage policy, and update your privacy policy to match. For how SiteTrellis stores and protects your key and chats, see Security and privacy.
Related: AI keys overview, Build your agent.