Custom Chatbots
15 min
Keep your LLM API key on the server and call the completions endpoint from your backend. Never embed a live key in a public JavaScript bundle or accept a provider URL from a visitor.
Send a bounded message history and handle quota errors explicitly. Stream text as SSE when useful; a disconnected request may still consume tokens or retain its reservation until usage is known.