Skip to main content
POST
Użyj tego endpointu, aby edytować jeden lub więcej obrazów za pomocą modeli obrazów Grok. Treść żądania używa application/json.

Podaj obrazy wejściowe

  • Wyślij dokładnie jedno z image lub images.
  • Użyj image dla jednego obrazu źródłowego.
  • Użyj images dla dwóch lub trzech obrazów źródłowych.
  • W każdym obiekcie obrazu użyj url dla publicznego adresu URL lub identyfikatora URI danych. image_url jest aliasem zgodności dla url.
  • Użyj aspect_ratio, aby kontrolować kształt danych wyjściowych w edycjach wielu obrazów.
Wybierz identyfikator modelu obrazu Grok na stronie modeli. Przykłady API używają grok-imagine-image-quality.
Wysyłaj żądania edycji obrazów Grok jako JSON. Dane formularza multipart nie odpowiadają strukturze tego żądania.
Metoda images.edit() SDK OpenAI wysyła dane formularza multipart. W przypadku edycji obrazów Grok w formacie JSON użyj bezpośredniego żądania HTTP. Szczegółowe informacje o parametrach dostawcy znajdziesz w przewodniku po edycji obrazów xAI.

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 instruction that describes the requested edit.

Minimum string length: 1
Przykład:

"Replace the daytime sky with a soft sunset and preserve the building"

image
object
wymagane

One source image. Use this field instead of images.

images
object[]

Two or three source images. Use this field instead of image.

Required array length: 2 - 3 elements

A source image represented by url or the compatibility alias image_url.

n
integer
domyślnie:1

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

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

The output shape for a multi-image edit.

Dostępne opcje:
1:1,
3:4,
4:3,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2
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 edited image results.

data
object[]
wymagane

The edited images.

Minimum array length: 1
usage
object
wymagane

Usage details for the request.