How to embed ChatGPT on your website safely
A chat box on your site is the easy part. Keeping keys private, limiting scope and handing off to people is the real work. See the safe pattern and an example embed.
Read articleA support bot that calls a model API fails in ordinary ways: slow replies, outages, leaked keys, bad inputs. A production-readiness list with a retry example to adapt.
By the Askocto team · · 4 min read
If you build a support bot on the Claude API, the model call is a dependency that will sometimes be slow, busy or unavailable, and customers will hit those moments. This article is a production-readiness list for any bot that calls a model API directly. It does not describe the API itself, so use the provider's current documentation for request formats, limits and terms. It covers what your own code has to do around the call.
In short: Treat the model call as an unreliable network dependency. Set timeouts, retry with backoff, keep keys on the server, version your instructions, check inputs and outputs, and log carefully.
A model call can be slow, can fail, or can return something your code did not expect. Plan for each:
A retry wrapper in JavaScript shows the pattern:
async function callWithRetry(makeRequest, { tries = 3, baseMs = 500 } = {}) {
for (let attempt = 1; attempt <= tries; attempt++) {
try {
const res = await makeRequest({ signal: AbortSignal.timeout(20000) })
if (res.ok) return await res.json()
const retryable = res.status === 429 || res.status >= 500
if (!retryable || attempt === tries) throw new Error(`status ${res.status}`)
const wait = Number(res.headers.get("retry-after")) * 1000 || baseMs * 2 ** attempt
await new Promise((r) => setTimeout(r, wait))
} catch (err) {
if (attempt === tries) throw err
await new Promise((r) => setTimeout(r, baseMs * 2 ** attempt))
}
}
}
Tune the timeout and the number of tries to your channel. A chat window tolerates a few seconds. A voice call does not.
| Risk | Control | How to test it |
|---|---|---|
| Slow or failed call | Timeout, capped retries, fallback message | Block the network and watch the customer view |
| Leaked key | Key on the server, loaded from the environment, rotated on a schedule | Search your front-end bundle and repository for it |
| Silent prompt edits | Instructions in version control with a change note | Compare two versions on your test set |
| Prompt injection | Rules in instructions and checks outside the model | Send "ignore your rules" messages |
| Personal data in logs | Redact before storing, set a retention period | Read a day of logs |
| Wrong answers | Retrieval from your sources, a decline rule, review | Run 50 questions, 10 of them traps |
| No human path | Handoff with transcript and summary | Ask for a person in every channel |
| Cost surprises | Usage alerts, limits per session | Run a long conversation and read the usage |
Work through the table with the people who will be paged when it fails. An item with no owner is an item that will fail.
Keys belong in server-side configuration, never in a web page, a mobile app bundle or a public repository. Give each environment its own key, rotate on a schedule, and revoke on a leak. For the chat window itself, your server should be the only thing that talks to the provider. If a customer's browser can call the model directly, anyone can.
The instructions that shape the bot are code in effect. Store them in version control, require a note for each change, and run your test set before and after. A single added sentence can shift behavior in unexpected cases, as the upgrade playbook for Claude 4 shows for model changes.
Checks outside the model are your safety net, because model instructions alone are not guaranteed to hold.
Logs help you review quality and debug. They also hold customer data. Store the question, the answer and the sources used, redact personal details, set a retention period and restrict access. This is not legal advice, so involve your privacy contact. Security questions for AI support vendors lists the questions to ask of a vendor, which you can turn on yourself as a checklist.
Everything above is work a platform takes on. Askocto, for example, returns structured errors, including a rate_limited code with a Retry-After header that your client can obey, as described in its error handling reference, and it adds handoff, logs and versions around the model. See the ChatGPT API guide for a plan of what building it yourself involves, and the DeepSeek API guide for how to design so you can change providers. If you would rather evaluate a ready platform, the product overview is the place to begin.
It is the model component. You add retrieval, memory, rules, handoff, logging and monitoring to make a bot you can trust with customers.
Read the provider's current limits, wait and retry with backoff when you get a slow-down response, and show a fallback message if it keeps failing.
On your server, in environment configuration. Never in front-end code, mobile apps or a repository.
If you use a support platform such as Askocto, retries, handoff, logs and versions come with it, and you configure the agent instead of writing the service.
Askocto answers the repeat questions across chat, email and voice and hands the hard ones to your team.
A chat box on your site is the easy part. Keeping keys private, limiting scope and handing off to people is the real work. See the safe pattern and an example embed.
Read articleFast models are tempting for chat and voice, but speed is only worth it if answers stay right. A protocol to measure latency and quality together on your own conversations.
Read articleUsing a model API in support means planning for slow calls, errors and changes. A pre-flight checklist and a thin wrapper keep Kimi K2 or any provider swappable.
Read article