stream: true, the response is sent as Server-Sent Events (SSE), with each token delivered incrementally. This provides a better user experience for longer responses.data: {"id":"chatcmpl_abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: [DONE]
stream: false or omitted, returns a complete response object.curl -X POST 'https://api.petstoreapi.com/v1/chat/completions' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{
"role": "user",
"content": "What should I know before adopting a cat?"
}
],
"model": "pet-advisor-1",
"stream": false
}'{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1702648800,
"model": "pet-advisor-1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Before adopting a cat, consider these important factors:\n\n1. **Time Commitment**: Cats can live 15-20 years\n2. **Space**: Ensure you have adequate living space\n3. **Allergies**: Check if anyone in your household has cat allergies\n4. **Costs**: Budget for food, litter, vet care, and supplies\n5. **Lifestyle**: Consider if your schedule allows for proper care\n\nWould you like recommendations for cats currently available for adoption?"
},
"finishReason": "stop"
}
],
"usage": {
"promptTokens": 15,
"completionTokens": 89,
"totalTokens": 104
}
}