Streaming Response
POST
https://api.x.ai/v1/chat/completions
"stream": true
in your request:
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.x.ai/v1/chat/completions' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages": [
{
"role": "system",
"content": "You are Grok, a chatbot inspired by the Hitchhikers Guide to the Galaxy."
},
{
"role": "user",
"content": "What is the meaning of life, the universe, and everything?"
}
],
"model": "grok-3-latest",
"stream": true,
"temperature": 0
}'
Response Response Example
{}
Request
Header Params
Content-Type
string
required
Example:
application/json
Authorization
string
required
Example:
Bearer {{XAI_API_KEY}}
Body Params application/json
Responses
Modified at 2025-04-10 08:51:55