Streaming
Streaming reduces time to first output and works well for chat and long-form generation.
curl -N https://cpa.momoyai.com/v1/chat/completions \ -H "Authorization: Bearer $MOMOYAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4-mini", "stream": true, "messages": [{"role": "user", "content": "List three API security practices."}] }'Client checklist
Section titled “Client checklist”- Use an HTTP client that exposes the stream.
- Parse event boundaries instead of assuming one network read is one event.
- Support cancellation and forward its signal to the request.
- Distinguish normal completion, upstream errors, timeouts, and client disconnects.
- Retry only requests that have not started producing user-visible output.