For the complete documentation index, see llms.txt. This page is also available as Markdown.

Grok 4.3

This documentation is valid for the following list of our models:

  • x-ai/grok-4-3

Model Overview

Grok 4.3 is a large language model by xAI for text generation and reasoning tasks. Supports up to 1M context tokens and is optimized for conversational AI and analytical workflows.

How to make the first API call

1️⃣ Required setup (don’t skip this)Create an account: Sign up on the AI/ML API website (if you don’t have one yet). ▪ Generate an API key: In your account dashboard, create an API key and make sure it’s enabled in the UI.

2️ Copy the code example At the bottom of this page, pick the snippet for your preferred programming language (Python / Node.js) and copy it into your project.

3️ Update the snippet for your use caseInsert your API key: replace <YOUR_AIMLAPI_KEY> with your real AI/ML API key. ▪ Select a model: set the model field to the model you want to call. ▪ Provide input: fill in the request input field(s) shown in the example.

4️ (Optional) Tune the request See the API schema below for optional generation settings.

5️ Run your code Run the updated code in your development environment.

API Schemas

post
Body
modelstring · enumRequiredPossible values:
providerstringOptional

Provider routing override. Use a source key such as openai, openrouter, xai, google, alibaba, minimax, moonshot, baidu, or togetherai to run that provider with no fallback; auto (default) uses the full fallback chain. Case-insensitive.

Example: auto
max_tokensnumber · min: 1Optional

The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.

streambooleanOptional

If set to True, the model response data will be streamed to the client as it is generated using server-sent events.

Default: false
tool_choiceany ofOptional

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default when no tools are present. auto is the default if tools are present.

string · enumOptional

none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.

Possible values:
or
or
or
or
normalize_tool_schemasbooleanOptional

Enable provider compatibility normalization for tool function JSON schemas.

parallel_tool_callsbooleanOptional

Whether to enable parallel function calling during tool use.

temperaturenumber · max: 2Optional

What sampling temperature to use. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.

top_pnumber · min: 0.01 · max: 1Optional

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. We generally recommend altering this or temperature but not both.

ninteger · min: 1 · nullableOptional

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.

logprobsboolean · nullableOptional

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.

top_logprobsnumber · max: 20 · nullableOptional

An integer between 0 and 20 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.

seedinteger · min: 1Optional

This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.

response_formatone ofOptional

An object specifying the format that the model must output.

or
or
echobooleanOptional

If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs.

min_pnumber · min: 0.001 · max: 0.999Optional

A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k.

top_knumberOptional

Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature.

top_anumber · max: 1Optional

Alternate top sampling parameter.

repetition_penaltynumber · nullableOptional

A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition.

search_modestring · enumOptional

Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals.

Default: academicPossible values:
search_domain_filterstring[]Optional

A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string.

return_imagesbooleanOptional

Determines whether search results should include images.

Default: false
return_related_questionsbooleanOptional

Determines whether related questions should be returned.

Default: false
search_recency_filterstring · enumOptional

Filters search results based on time (e.g., 'week', 'day').

Possible values:
search_after_date_filterstringOptional

Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)

Pattern: ^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/\d{4}$
search_before_date_filterstringOptional

Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)

Pattern: ^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/\d{4}$
last_updated_after_filterstringOptional

Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)

Pattern: ^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/\d{4}$
last_updated_before_filterstringOptional

Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)

Pattern: ^(0?[1-9]|1[0-2])\/(0?[1-9]|[12]\d|3[01])\/\d{4}$
Responses
200

Successful response.

idstringRequired

A unique identifier for the chat completion.

Example: chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl
objectstring · enumRequired

The object type.

Example: chat.completionPossible values:
creatednumberRequired

The Unix timestamp (in seconds) of when the chat completion was created.

Example: 1762343744
modelstringRequired

The model used for the chat completion.

Example: x-ai/grok-4-3
post/v1/chat/completions
200

Successful response.

post
Body
modelstring · enumRequiredPossible values:
inputany ofRequired

Text, image, or file inputs to the model, used to generate a response.

stringOptional

A text input to the model, equivalent to a text input with the user role.

or
backgroundbooleanOptional

Whether to run the model response in the background.

Default: false
instructionsstring · nullableOptional

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

When using along with previous_response_id, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.

max_output_tokensinteger · min: 16Optional

An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.

previous_response_idstring · nullableOptional

The unique ID of the previous response to the model. Use this to create multi-turn conversations.

storeboolean · nullableOptional

Whether to store the generated model response for later retrieval via API.

Default: false
streamboolean · nullableOptional

If set to true, the model response data will be streamed to the client as it is generated using server-sent events.

Default: false
truncationstring · enumOptional

The truncation strategy to use for the model response.

  • auto: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.
  • disabled (default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
Default: disabledPossible values:
tool_choiceany ofOptional

How the model should select which tool (or tools) to use when generating a response.

string · enumOptional

Controls which (if any) tool is called by the model.

none means the model will not call any tool and instead generates a message.

auto means the model can pick between generating a message or calling one or more tools.

required means the model must call one or more tools.

Possible values:
or
or
parallel_tool_callsboolean · nullableOptional

Whether to allow the model to run tool calls in parallel.

Responses
200

Successful response.

backgroundboolean · nullableOptional

Whether to run the model response in the background.

Example: false
created_atnumberRequired

Unix timestamp (in seconds) of when this Response was created.

Example: 1762343744
idstringRequired

Unique identifier for this Response.

Example: resp_68963fb142d08197b4d3ae3ad852542c054845c6ea84caa2
instructionsany ofOptional

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

stringOptional

A text input to the model, equivalent to a text input with the developer role.

or
or
any · nullableOptional
max_output_tokensinteger · nullableOptional

An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.

modelstringRequired

Model ID used to generate the response.

Example: x-ai/grok-4-3
objectstring · enumRequired

The object type of this resource - always set to response.

Example: responsePossible values:
output_textstring · nullableOptional

SDK-only convenience property that contains the aggregated text output from all output_text items in the output array, if any are present. Supported in the Python and JavaScript SDKs.

Example: Hi! How’s your day going?
parallel_tool_callsbooleanRequired

Whether to allow the model to run tool calls in parallel.

Example: false
previous_response_idstring · nullableOptional

The unique ID of the previous response to the model. Use this to create multi-turn conversations.

service_tierstring · nullableOptional

Specifies the processing type used for serving the request.

statusstring · enumOptional

The status of the response generation.

Example: completedPossible values:
temperaturenumber · max: 2 · nullableOptional

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. We generally recommend altering this or top_p but not both.

tool_choiceany ofOptional

How the model should select which tool (or tools) to use when generating a response.

string · enumOptional

Controls which (if any) tool is called by the model.

none means the model will not call any tool and instead generates a message.

auto means the model can pick between generating a message or calling one or more tools.

required means the model must call one or more tools.

Possible values:
or
or
or
any · nullableOptional
top_pnumber · nullableOptional

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.

We generally recommend altering this or temperature but not both.

truncationstring · enum · nullableOptional

The truncation strategy to use for the model response.

  • auto: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.
  • disabled (default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
Possible values:
citationsstring · uri[]Optional
post/v1/responses
200

Successful response.

Code Example

Response

Last updated

Was this helpful?