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

  • Base URL: https://docs.x.ai (the document declares no server; this is the origin it was published from)
  • URL: https://docs.x.ai/v1/responses
  • Auth: HTTP bearer

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. Only applies to visible output tokens (i.e. does not apply to tokens used for reasoning or function calls). 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, and for agentic SLOP requests that have neither a server-side tool nor a file attachment.

metadataunknown
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

Non-standard alternative to reasoning.effort that accepts the same values. We only look at this if the reasoning field is unset.

safety_identifierstring nullable

Supplied by the API client to identify the end user behind this request. A stable string that uniquely identifies each of your users; hash your internal user id or username rather than sending an email or name. Stored with the request metadata so a usage-policy violation can be attributed to that user rather than to the API key.

service_tier'default' | 'priority' | 'fast'

Processing tier for a request. Fast and Priority are interchangeable: the model's fast deployment and its rates where configured, else higher scheduling priority at a higher price.

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.

errorunknown
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. Only applies to visible output tokens (i.e. does not apply to tokens used for reasoning or function calls).

max_tool_callsinteger nullable

The maximum number of tool calls allowed for this response.

metadataunknown required
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' | 'fast' required

Processing tier for a request. Fast and Priority are interchangeable: the model's fast deployment and its rates where configured, else higher scheduling priority at a higher price.

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.

Changes

No recorded changes to this operation across all 1 revision of this API.