v4

latestOpenAPI 3.1.02026-08-0143190206.8 KB
v1

Generates a response based on text or image prompts. The response ID can be used to retrieve the response later or to continue the conversation without repeating prior context. New responses will be stored for 30 days and then permanently deleted.

post/v1/responses

Request body

backgroundboolean nullable

(Unsupported) Whether to process the response asynchronously in the background.

includestring[] nullable

What additional output data to include in the response. Supported values include reasoning.encrypted_content (encrypted reasoning tokens) and tool-output options. OpenAI's message.output_text.logprobs is accepted for compatibility but silently ignored.

instructionsstring nullable

An alternate way to specify the system prompt. Note that this cannot be used alongside previous_response_id, where the system prompt of the previous message will be used.

logprobsboolean nullable

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. Not supported by models grok-4.20 and newer; the field will be silently ignored if set.

max_output_tokensinteger nullable

Max number of tokens that can be generated in a response. This includes both output and reasoning tokens. Defaults to 128,000 when unset; set a larger value to allow longer generations.

max_turnsinteger nullable

Maximum number of agentic tool calling turns allowed for this request. If not set, defaults to the server's global cap. This parameter will be ignored for any non-agentic requests.

{"stackTrail":"components:schemas:ModelRequest:properties:metadata","oasType":"schema","type":"unknown","description":"Not supported. Only maintained for compatibility reasons."}
min_pnumber float nullable

Min-p sampling: tokens whose probability is below min_p times the probability of the most likely token are excluded from sampling. Disabled when unset.

modelstring

Model name for the model to use. Obtainable from https://console.x.ai/team/default/models or https://docs.x.ai/docs/models.

parallel_tool_callsboolean nullable

Whether to allow the model to run parallel tool calls.

previous_response_idstring nullable

The ID of the previous response from the model.

prompt_cache_keystring nullable

Plumbed to x-grok-conv-id for Open Responses compatibility, used for routing.

reasoning_effortstring nullable

reasoning_effort alternative to reasoning configuration. This is a non-standard field meant to ease user experience. We only look at this if the reasoning field is unset.

service_tier'default' | 'priority'

Processing tier for a request. Determines scheduling priority and billing.

storeboolean nullable

Whether to store the input message(s) and model response for later retrieval.

streamboolean nullable

If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

temperaturenumber float nullable

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

top_kinteger nullable

Top-k sampling: only the top_k most probable tokens are considered at each sampling step. Disabled when unset.

top_logprobsinteger nullable

An integer between 0 and 8 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used. Not supported by models grok-4.20 and newer; the field will be silently ignored if set.

top_pnumber float nullable

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. It is generally recommended to alter this or temperature but not both.

truncationstring nullable

Not supported. Only maintained for compatibility reasons.

userstring nullable

A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.

Response

Success

backgroundboolean required

OpenResponses compatibility fields. Not used at the moment. Just for OpenResponses compatibility. Whether to process the response asynchronously in the background.

completed_atinteger nullable

The Unix timestamp (in seconds) for the response completion time. Only set when the response is completed.

created_atinteger required

The Unix timestamp (in seconds) for the response creation time.

{"stackTrail":"components:schemas:ModelResponse:properties:error","oasType":"schema","type":"unknown","description":"An error object returned when the model fails to generate a response."}
frequency_penaltynumber float required

(NOT SUPPORTED in Responses API) Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

idstring required

Unique ID of the response.

instructionsstring nullable

A system (or developer) message inserted into the model's context.

max_output_tokensinteger nullable

Max number of tokens that can be generated in a response. This includes both output and reasoning tokens.

max_tool_callsinteger nullable

The maximum number of tool calls allowed for this response.

{"stackTrail":"components:schemas:ModelResponse:properties:metadata","oasType":"schema","type":"unknown","description":"Only included for compatibility."}
modelstring required

Model name used to generate the response.

objectstring required

The object type of this resource. Always set to response.

parallel_tool_callsboolean required

Whether to allow the model to run parallel tool calls.

presence_penaltynumber float required

(NOT SUPPORTED in Responses API) Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

previous_response_idstring nullable

The ID of the previous response from the model.

prompt_cache_keystring nullable

The cache key used for the prompt for routing to the correct engine.

safety_identifierstring nullable

A stable identifier used to help detect users of your application that may be violating xAI's usage policies.

service_tier'default' | 'priority' required

Processing tier for a request. Determines scheduling priority and billing.

statusstring required

Status of the response. One of completed, in_progress or incomplete.

storeboolean required

Whether to store the input message(s) and model response for later retrieval.

temperaturenumber float nullable

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

top_logprobsinteger required

An integer between 0 and 8 specifying the number of most likely tokens to return at each token position.

top_pnumber float nullable

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. It is generally recommended to alter this or temperature but not both.

truncationstring required

The truncation strategy to use for the model response.

userstring nullable

A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.