> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/workflows/blocks/blocks/run-a-model/spacexai.md).

# SpaceXAI

Run SpaceXAI Grok models with vision capabilities.

## v3

Ask a question to SpaceXAI Grok models with vision capabilities.

You can specify arbitrary text prompts or predefined ones, the block supports the following types of prompt:

* **Open Prompt** (`unconstrained`) - Use any prompt to generate a raw response
* **Text Recognition (OCR)** (`ocr`) - Model recognizes text in the image
* **Visual Question Answering** (`visual-question-answering`) - Model answers the question you submit in the prompt
* **Captioning (short)** (`caption`) - Model provides a short description of the image
* **Captioning** (`detailed-caption`) - Model provides a long description of the image
* **Single-Label Classification** (`classification`) - Model classifies the image content as one of the provided classes
* **Multi-Label Classification** (`multi-label-classification`) - Model classifies the image content as one or more of the provided classes
* **Unprompted Object Detection** (`object-detection`) - Model detects and returns the bounding boxes for prominent objects in the image
* **Structured Output Generation** (`structured-answering`) - Model returns a JSON response with the specified fields

The `object-detection` task asks Grok for a JSON list of `{"label": ..., "box_2d": [x_min, y_min, x_max, y_max]}` entries where coordinates are percentages of image width and height (floats 0-100). Confidence scores are optional; when absent decoded detections are assigned `1.0`.

Images for object detection are sent at original resolution as lossless PNG with `detail: "high"`, matching the vlm-exam benchmark setup for Grok 4.5/4.6. Grok 4.7 uses the same prompt and image handling.

## Version Differences

This version (v3) decodes the model answer inside the block, adding `predictions`, `error_status` and `inference_id` outputs next to the raw `output` string:

* `predictions` holds object detections for the `object-detection` task and a classification prediction for the `classification` / `multi-label-classification` tasks - the kind of the output follows the selected task type.
* `predictions` is `None` for every other task (unconstrained prompting, OCR, captioning, structured answering, visual question answering).
* `error_status` is `True` when the answer could not be decoded.
* `inference_id` is generated per image.

Separate `roboflow_core/vlm_as_detector@v2` and `roboflow_core/vlm_as_classifier@v2` steps are no longer needed.

### API Key Options

1. **Roboflow Managed API Key (Default)** - Use `rf_key:account` to proxy requests through Roboflow's API. Usage is billed against Roboflow credits.
2. **Custom xAI API Key** - Provide your own xAI API key and pay xAI directly.

### Type identifier

Use the following identifier in step `"type"` field: `roboflow_core/spacexai@v3` to add the block as a step in your workflow.

### Properties

| **Name**                  | **Type**         | **Description**                                                                                                                                                                                                                                                                                                                     | Refs |
| ------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| `name`                    | `str`            | Enter a unique identifier for this step..                                                                                                                                                                                                                                                                                           | ❌    |
| `task_type`               | `str`            | Task type to be performed by model. Value determines required parameters and output response..                                                                                                                                                                                                                                      | ❌    |
| `prompt`                  | `str`            | Text prompt to the Grok model.                                                                                                                                                                                                                                                                                                      | ✅    |
| `output_structure`        | `Dict[str, str]` | Dictionary with structure of expected JSON response.                                                                                                                                                                                                                                                                                | ❌    |
| `classes`                 | `List[str]`      | List of classes to be used.                                                                                                                                                                                                                                                                                                         | ✅    |
| `api_key`                 | `str`            | Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.                                                                                                                                                                                                                                                            | ✅    |
| `model_version`           | `str`            | Model to be used.                                                                                                                                                                                                                                                                                                                   | ✅    |
| `reasoning_effort`        | `str`            | Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. Grok models default to "high" and cannot disable reasoning. "xhigh" is not supported by grok-4.5. With a direct xAI key, if the model rejects the `reasoning` parameter the request is retried without it, so the model falls back to its default effort.. | ✅    |
| `max_tokens`              | `int`            | Maximum number of tokens the model can generate in its response. If not specified, the model will use its default limit. Minimum value is 16..                                                                                                                                                                                      | ❌    |
| `temperature`             | `float`          | Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..                                                                                                                                                                                                      | ✅    |
| `max_concurrent_requests` | `int`            | Number of concurrent requests that can be executed by block when batch of input images provided. If not given - block defaults to value configured globally in Workflows Execution Engine. Please restrict if you hit xAI limits..                                                                                                  | ❌    |

The **Refs** column marks possibility to parametrise the property with dynamic values available in `workflow` runtime. See *Bindings* for more info.

### Runtime compatibility

`requires_internet` - air-gapped / offline deployments : This block depends on a service that is not reachable from fully offline / air-gapped deployments.

### Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds `SpaceXAI` in version `v3` has.

<details>

<summary>Input and output bindings</summary>

* input
  * `images` ([*`image`*](/workflows/developer-guide/developer-guide/kinds/image.md)): The image to infer on..
  * `prompt` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Text prompt to the Grok model.
  * `classes` ([*`list_of_values`*](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of classes to be used.
  * `api_key` (*Union\[*[*`ROBOFLOW_MANAGED_KEY`*](/workflows/developer-guide/developer-guide/kinds/roboflow-managed-key.md)*,* [*`secret`*](/workflows/developer-guide/developer-guide/kinds/secret.md)*,* [*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*]*): Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.
  * `model_version` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Model to be used.
  * `reasoning_effort` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. Grok models default to "high" and cannot disable reasoning. "xhigh" is not supported by grok-4.5. With a direct xAI key, if the model rejects the `reasoning` parameter the request is retried without it, so the model falls back to its default effort..
  * `temperature` ([*`float`*](/workflows/developer-guide/developer-guide/kinds/float.md)): Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..
* output
  * `output` (*Union\[*[*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*,* [*`language_model_output`*](/workflows/developer-guide/developer-guide/kinds/language-model-output.md)*]*): String value if `string` or LLM / VLM output if `language_model_output`.
  * `classes` ([`list_of_values`](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of values of any type.
  * `input_tokens` ([`integer`](/workflows/developer-guide/developer-guide/kinds/integer.md)): Integer value.
  * `output_tokens` ([`integer`](/workflows/developer-guide/developer-guide/kinds/integer.md)): Integer value.
  * `predictions` (*Union\[*[*`object_detection_prediction`*](/workflows/developer-guide/developer-guide/kinds/object-detection-prediction.md)*,* [*`classification_prediction`*](/workflows/developer-guide/developer-guide/kinds/classification-prediction.md)*]*): Prediction with detected bounding boxes in form of sv.Detections(...) object if `object_detection_prediction` or Predictions from classifier if `classification_prediction`.
  * `error_status` ([`boolean`](/workflows/developer-guide/developer-guide/kinds/boolean.md)): Boolean flag.
  * `inference_id` ([`inference_id`](/workflows/developer-guide/developer-guide/kinds/inference-id.md)): Inference identifier.

</details>

<details>

<summary>Example JSON definition</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/spacexai@v3",
	    "images": "$inputs.image",
	    "task_type": "<block_does_not_provide_example>",
	    "prompt": "my prompt",
	    "output_structure": {
	        "my_key": "description"
	    },
	    "classes": [
	        "class-a",
	        "class-b"
	    ],
	    "api_key": "rf_key:account",
	    "model_version": "grok-4.7",
	    "reasoning_effort": "low",
	    "max_tokens": "<block_does_not_provide_example>",
	    "temperature": "<block_does_not_provide_example>",
	    "max_concurrent_requests": "<block_does_not_provide_example>"
	}
```

</details>

## v2

Ask a question to SpaceXAI Grok models with vision capabilities.

You can specify arbitrary text prompts or predefined ones, the block supports the following types of prompt:

* **Open Prompt** (`unconstrained`) - Use any prompt to generate a raw response
* **Text Recognition (OCR)** (`ocr`) - Model recognizes text in the image
* **Visual Question Answering** (`visual-question-answering`) - Model answers the question you submit in the prompt
* **Captioning (short)** (`caption`) - Model provides a short description of the image
* **Captioning** (`detailed-caption`) - Model provides a long description of the image
* **Single-Label Classification** (`classification`) - Model classifies the image content as one of the provided classes
* **Multi-Label Classification** (`multi-label-classification`) - Model classifies the image content as one or more of the provided classes
* **Unprompted Object Detection** (`object-detection`) - Model detects and returns the bounding boxes for prominent objects in the image
* **Structured Output Generation** (`structured-answering`) - Model returns a JSON response with the specified fields

The `object-detection` task asks Grok for a JSON list of `{"label": ..., "box_2d": [x_min, y_min, x_max, y_max]}` entries where coordinates are percentages of image width and height (floats 0-100). Use `roboflow_core/vlm_as_detector@v2` with `model_type="spacexai"` to convert the output into predictions. Confidence scores are optional; when absent the parser assigns `1.0`.

Images for object detection are sent at original resolution as lossless PNG with `detail: "high"`, matching the vlm-exam benchmark setup for Grok 4.5/4.6.

### API Key Options

1. **Roboflow Managed API Key (Default)** - Use `rf_key:account` to proxy requests through Roboflow's API. Usage is billed against Roboflow credits.
2. **Custom xAI API Key** - Provide your own xAI API key and pay xAI directly.

### Type identifier

Use the following identifier in step `"type"` field: `roboflow_core/spacexai@v2` to add the block as a step in your workflow.

### Properties

| **Name**                  | **Type**         | **Description**                                                                                                                                                                                                                                                                                 | Refs |
| ------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| `name`                    | `str`            | Enter a unique identifier for this step..                                                                                                                                                                                                                                                       | ❌    |
| `task_type`               | `str`            | Task type to be performed by model. Value determines required parameters and output response..                                                                                                                                                                                                  | ❌    |
| `prompt`                  | `str`            | Text prompt to the Grok model.                                                                                                                                                                                                                                                                  | ✅    |
| `output_structure`        | `Dict[str, str]` | Dictionary with structure of expected JSON response.                                                                                                                                                                                                                                            | ❌    |
| `classes`                 | `List[str]`      | List of classes to be used.                                                                                                                                                                                                                                                                     | ✅    |
| `api_key`                 | `str`            | Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.                                                                                                                                                                                                                        | ✅    |
| `model_version`           | `str`            | Model to be used.                                                                                                                                                                                                                                                                               | ✅    |
| `reasoning_effort`        | `str`            | Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. Grok models default to "high" and cannot disable reasoning. "xhigh" is only supported by grok-4.6. For requests with a direct xAI key, the request is retried without reasoning when the model rejects the parameter.. | ✅    |
| `max_tokens`              | `int`            | Maximum number of tokens the model can generate in its response. If not specified, the model will use its default limit. Minimum value is 16..                                                                                                                                                  | ❌    |
| `temperature`             | `float`          | Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..                                                                                                                                                                  | ✅    |
| `max_concurrent_requests` | `int`            | Number of concurrent requests that can be executed by block when batch of input images provided. If not given - block defaults to value configured globally in Workflows Execution Engine. Please restrict if you hit xAI limits..                                                              | ❌    |

The **Refs** column marks possibility to parametrise the property with dynamic values available in `workflow` runtime. See *Bindings* for more info.

### Runtime compatibility

`requires_internet` - air-gapped / offline deployments : This block depends on a service that is not reachable from fully offline / air-gapped deployments.

### Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds `SpaceXAI` in version `v2` has.

<details>

<summary>Input and output bindings</summary>

* input
  * `images` ([*`image`*](/workflows/developer-guide/developer-guide/kinds/image.md)): The image to infer on..
  * `prompt` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Text prompt to the Grok model.
  * `classes` ([*`list_of_values`*](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of classes to be used.
  * `api_key` (*Union\[*[*`ROBOFLOW_MANAGED_KEY`*](/workflows/developer-guide/developer-guide/kinds/roboflow-managed-key.md)*,* [*`secret`*](/workflows/developer-guide/developer-guide/kinds/secret.md)*,* [*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*]*): Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.
  * `model_version` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Model to be used.
  * `reasoning_effort` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. Grok models default to "high" and cannot disable reasoning. "xhigh" is only supported by grok-4.6. For requests with a direct xAI key, the request is retried without reasoning when the model rejects the parameter..
  * `temperature` ([*`float`*](/workflows/developer-guide/developer-guide/kinds/float.md)): Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..
* output
  * `output` (*Union\[*[*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*,* [*`language_model_output`*](/workflows/developer-guide/developer-guide/kinds/language-model-output.md)*]*): String value if `string` or LLM / VLM output if `language_model_output`.
  * `classes` ([`list_of_values`](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of values of any type.
  * `input_tokens` ([`integer`](/workflows/developer-guide/developer-guide/kinds/integer.md)): Integer value.
  * `output_tokens` ([`integer`](/workflows/developer-guide/developer-guide/kinds/integer.md)): Integer value.

</details>

<details>

<summary>Example JSON definition</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/spacexai@v2",
	    "images": "$inputs.image",
	    "task_type": "<block_does_not_provide_example>",
	    "prompt": "my prompt",
	    "output_structure": {
	        "my_key": "description"
	    },
	    "classes": [
	        "class-a",
	        "class-b"
	    ],
	    "api_key": "rf_key:account",
	    "model_version": "grok-4.6",
	    "reasoning_effort": "low",
	    "max_tokens": "<block_does_not_provide_example>",
	    "temperature": "<block_does_not_provide_example>",
	    "max_concurrent_requests": "<block_does_not_provide_example>"
	}
```

</details>

## v1

Ask a question to SpaceXAI Grok models with vision capabilities.

You can specify arbitrary text prompts or predefined ones, the block supports the following types of prompt:

* **Open Prompt** (`unconstrained`) - Use any prompt to generate a raw response
* **Text Recognition (OCR)** (`ocr`) - Model recognizes text in the image
* **Visual Question Answering** (`visual-question-answering`) - Model answers the question you submit in the prompt
* **Captioning (short)** (`caption`) - Model provides a short description of the image
* **Captioning** (`detailed-caption`) - Model provides a long description of the image
* **Single-Label Classification** (`classification`) - Model classifies the image content as one of the provided classes
* **Multi-Label Classification** (`multi-label-classification`) - Model classifies the image content as one or more of the provided classes
* **Unprompted Object Detection** (`object-detection`) - Model detects and returns the bounding boxes for prominent objects in the image
* **Structured Output Generation** (`structured-answering`) - Model returns a JSON response with the specified fields

The `object-detection` task asks Grok for a JSON list of `{"label": ..., "box_2d": [x_min, y_min, x_max, y_max]}` entries where coordinates are percentages of image width and height (floats 0-100). Use `roboflow_core/vlm_as_detector@v2` with `model_type="spacexai"` to convert the output into predictions. Confidence scores are optional; when absent the parser assigns `1.0`.

Images for object detection are sent at original resolution as lossless PNG with `detail: "high"`, matching the vlm-exam benchmark setup for Grok 4.5/4.6.

### API Key Options

1. **Roboflow Managed API Key (Default)** - Use `rf_key:account` to proxy requests through Roboflow's API. Usage is billed against Roboflow credits.
2. **Custom xAI API Key** - Provide your own xAI API key and pay xAI directly.

### Type identifier

Use the following identifier in step `"type"` field: `roboflow_core/spacexai@v1` to add the block as a step in your workflow.

### Properties

| **Name**                  | **Type**         | **Description**                                                                                                                                                                                                                    | Refs |
| ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| `name`                    | `str`            | Enter a unique identifier for this step..                                                                                                                                                                                          | ❌    |
| `task_type`               | `str`            | Task type to be performed by model. Value determines required parameters and output response..                                                                                                                                     | ❌    |
| `prompt`                  | `str`            | Text prompt to the Grok model.                                                                                                                                                                                                     | ✅    |
| `output_structure`        | `Dict[str, str]` | Dictionary with structure of expected JSON response.                                                                                                                                                                               | ❌    |
| `classes`                 | `List[str]`      | List of classes to be used.                                                                                                                                                                                                        | ✅    |
| `api_key`                 | `str`            | Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.                                                                                                                                                           | ✅    |
| `model_version`           | `str`            | Model to be used.                                                                                                                                                                                                                  | ✅    |
| `reasoning_effort`        | `str`            | Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. For requests with a direct xAI key, the request is retried without reasoning when the model rejects the parameter..                                       | ✅    |
| `max_tokens`              | `int`            | Maximum number of tokens the model can generate in its response. If not specified, the model will use its default limit. Minimum value is 16..                                                                                     | ❌    |
| `temperature`             | `float`          | Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..                                                                                                     | ✅    |
| `max_concurrent_requests` | `int`            | Number of concurrent requests that can be executed by block when batch of input images provided. If not given - block defaults to value configured globally in Workflows Execution Engine. Please restrict if you hit xAI limits.. | ❌    |

The **Refs** column marks possibility to parametrise the property with dynamic values available in `workflow` runtime. See *Bindings* for more info.

### Runtime compatibility

`requires_internet` - air-gapped / offline deployments : This block depends on a service that is not reachable from fully offline / air-gapped deployments.

### Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds `SpaceXAI` in version `v1` has.

<details>

<summary>Input and output bindings</summary>

* input
  * `images` ([*`image`*](/workflows/developer-guide/developer-guide/kinds/image.md)): The image to infer on..
  * `prompt` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Text prompt to the Grok model.
  * `classes` ([*`list_of_values`*](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of classes to be used.
  * `api_key` (*Union\[*[*`ROBOFLOW_MANAGED_KEY`*](/workflows/developer-guide/developer-guide/kinds/roboflow-managed-key.md)*,* [*`secret`*](/workflows/developer-guide/developer-guide/kinds/secret.md)*,* [*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*]*): Your xAI API key or 'rf\_key:account' to use Roboflow's managed API key.
  * `model_version` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Model to be used.
  * `reasoning_effort` ([*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)): Optional reasoning effort passed to xAI as `reasoning: {"effort": ...}`. For requests with a direct xAI key, the request is retried without reasoning when the model rejects the parameter..
  * `temperature` ([*`float`*](/workflows/developer-guide/developer-guide/kinds/float.md)): Temperature to sample from the model - value in range 0.0-2.0, the higher - the more random / "creative" the generations are..
* output
  * `output` (*Union\[*[*`string`*](/workflows/developer-guide/developer-guide/kinds/string.md)*,* [*`language_model_output`*](/workflows/developer-guide/developer-guide/kinds/language-model-output.md)*]*): String value if `string` or LLM / VLM output if `language_model_output`.
  * `classes` ([`list_of_values`](/workflows/developer-guide/developer-guide/kinds/list-of-values.md)): List of values of any type.

</details>

<details>

<summary>Example JSON definition</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/spacexai@v1",
	    "images": "$inputs.image",
	    "task_type": "<block_does_not_provide_example>",
	    "prompt": "my prompt",
	    "output_structure": {
	        "my_key": "description"
	    },
	    "classes": [
	        "class-a",
	        "class-b"
	    ],
	    "api_key": "rf_key:account",
	    "model_version": "grok-4.6",
	    "reasoning_effort": "low",
	    "max_tokens": "<block_does_not_provide_example>",
	    "temperature": "<block_does_not_provide_example>",
	    "max_concurrent_requests": "<block_does_not_provide_example>"
	}
```

</details>
