Skip to main content
POST
Użyj tej trasy, aby tworzyć obrazy z tekstu za pomocą modeli obrazów Grok. Treść żądania używa application/json. Żądanie obsługuje model, prompt, n, aspect_ratio, resolution i response_format.

Wybierz model

Wybierz identyfikator modelu obrazu Grok na stronie modeli. Przykłady API używają grok-imagine-image-quality.

Skonfiguruj dane wyjściowe

  • Użyj aspect_ratio, aby wybrać format danych wyjściowych, lub auto, aby pozwolić modelowi wybrać format.
  • Użyj resolution, aby zażądać danych wyjściowych 1k lub 2k.
  • Użyj n, aby zażądać maksymalnie 10 obrazów.
  • Użyj response_format, aby zwrócić tymczasowe adresy URL lub dane obrazu zakodowane w Base64.
Szczegółowe informacje o parametrach dostawcy znajdziesz w przewodniku generowania obrazów xAI.
Pobierz wyniki URL po zakończeniu żądania. Adresy URL wygenerowanych obrazów mogą wygasnąć.

Autoryzacje

Authorization
string
header
wymagane

Use your CometAPI API key as the bearer value.

Treść

application/json
model
enum<string>
wymagane

The Grok image model ID. See the Models page for available model IDs.

Dostępne opcje:
grok-imagine-image,
grok-imagine-image-quality
Przykład:

"grok-imagine-image-quality"

prompt
string
wymagane

A text description of the image to generate.

Minimum string length: 1
Przykład:

"A glass observatory above a quiet alpine lake at sunrise"

n
integer
domyślnie:1

The number of images to generate. Use an integer from 1 through 10.

Wymagany zakres: 1 <= x <= 10
aspect_ratio
enum<string>

The output shape. Use auto to let the model select the aspect ratio.

Dostępne opcje:
1:1,
3:4,
4:3,
9:16,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2,
2:1,
auto
Przykład:

"16:9"

resolution
enum<string>

The requested output resolution.

Dostępne opcje:
1k,
2k
Przykład:

"1k"

response_format
enum<string>
domyślnie:url

The image representation in each response item. Use url for a temporary download URL or b64_json for Base64-encoded image bytes.

Dostępne opcje:
url,
b64_json

Odpowiedź

200 - application/json

The generated image results.

data
object[]
wymagane

The generated images.

Minimum array length: 1
usage
object
wymagane

Usage details for the request.