Safe streaming AI endpoint
2 hOne API route that streams an AI answer, with input and cost limits.
- Read the API key only on the server
- Limit the question to 500 characters with Zod
- Set max_tokens and stream the reply
- Return a friendly error if the AI service fails
Done when: The key never reaches the browser, and long or empty questions are rejected.
- AI APIs
- Streaming
- Cost control