> ## Documentation Index
> Fetch the complete documentation index at: https://docs.artificialstudio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Imagine

> Highly aesthetic image generation by xAI.

|             |                |
| ----------- | -------------- |
| **Credits** | 4 credits      |
| **Tool**    | `create-image` |

### Headers

| Name            | Type   | Required | Description        |
| --------------- | ------ | -------- | ------------------ |
| `Authorization` | string | Yes      | Your API key       |
| `Content-Type`  | string | Yes      | `application/json` |

### Body

| Parameter            | Type   | Required | Description                                                                                              |
| -------------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------- |
| `tool`               | string | Yes      | `create-image`                                                                                           |
| `input.model`        | string | Yes      | `grok-imagine`                                                                                           |
| `input.prompt`       | string | Yes      | Text prompt for image generation                                                                         |
| `input.aspect_ratio` | string | No       | Aspect ratio. One of `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `2:1`, `1:2`. Defaults to `1:1`. |

<RequestExample>
  ```bash bash theme={null}
  curl -X POST https://api.artificialstudio.ai/api/run \
    -H "Content-Type: application/json" \
    -H "Authorization: YOUR_API_KEY" \
    -d '{
      "tool": "create-image",
      "input": {
        "model": "grok-imagine",
        "prompt": "A futuristic astronaut relaxing on the surface of Mars, cinematic style"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.artificialstudio.ai/api/run', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'YOUR_API_KEY'
    },
    body: JSON.stringify({
      tool: 'create-image',
      input: {
        model: 'grok-imagine',
        prompt: 'A futuristic astronaut relaxing on the surface of Mars, cinematic style'
      }
    })
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.artificialstudio.ai/api/run',
      headers={
          'Content-Type': 'application/json',
          'Authorization': 'YOUR_API_KEY'
      },
      json={
          'tool': 'create-image',
          'input': {
              'model': 'grok-imagine',
              'prompt': 'A futuristic astronaut relaxing on the surface of Mars, cinematic style'
          }
      }
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "507f1f77bcf86cd799439011",
    "status": "processing",
    "tool": "create-image",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
  ```

  ```json 400 theme={null}
  {
    "message": "Missing or invalid parameters"
  }
  ```

  ```json 401 theme={null}
  {
    "message": "Invalid or missing API key"
  }
  ```

  ```json 402 theme={null}
  {
    "message": "You do not have enough credits to perform this action"
  }
  ```

  ```json 429 theme={null}
  {
    "message": "Too many API requests, please try again later"
  }
  ```
</ResponseExample>
