生成图片
curl --request POST \
--url https://api.mountsea.ai/xai/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a cute cat sitting on a windowsill",
"model": "grok-imagine-image",
"images": [
"<string>"
]
}
'import requests
url = "https://api.mountsea.ai/xai/images"
payload = {
"prompt": "a cute cat sitting on a windowsill",
"model": "grok-imagine-image",
"images": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'a cute cat sitting on a windowsill',
model: 'grok-imagine-image',
images: ['<string>']
})
};
fetch('https://api.mountsea.ai/xai/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mountsea.ai/xai/images",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'a cute cat sitting on a windowsill',
'model' => 'grok-imagine-image',
'images' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mountsea.ai/xai/images"
payload := strings.NewReader("{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mountsea.ai/xai/images")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mountsea.ai/xai/images")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"taskId": "<string>"
}XAI (Grok)
grok image generation
根据文本提示词生成图片,可选传入参考图片实现图生图/编辑。 返回 taskId,使用 /xai/tasks 查询结果
POST
/
xai
/
images
生成图片
curl --request POST \
--url https://api.mountsea.ai/xai/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a cute cat sitting on a windowsill",
"model": "grok-imagine-image",
"images": [
"<string>"
]
}
'import requests
url = "https://api.mountsea.ai/xai/images"
payload = {
"prompt": "a cute cat sitting on a windowsill",
"model": "grok-imagine-image",
"images": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'a cute cat sitting on a windowsill',
model: 'grok-imagine-image',
images: ['<string>']
})
};
fetch('https://api.mountsea.ai/xai/images', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mountsea.ai/xai/images",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'a cute cat sitting on a windowsill',
'model' => 'grok-imagine-image',
'images' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mountsea.ai/xai/images"
payload := strings.NewReader("{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mountsea.ai/xai/images")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mountsea.ai/xai/images")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"a cute cat sitting on a windowsill\",\n \"model\": \"grok-imagine-image\",\n \"images\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"taskId": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
图片描述提示词(最大 5000 字符)
Maximum string length:
5000Example:
"a cute cat sitting on a windowsill"
图片模型
Available options:
grok-imagine-image, grok-imagine-image-quality Example:
"grok-imagine-image"
图片宽高比
Available options:
2:3, 3:2, 1:1, 9:16, 16:9 参考图片 URL(图生图 / 编辑图片,最多 5 张, 提供后图片尺寸跟随参考图片)
Maximum array length:
5Response
200 - application/json
任务 ID,用于后续查询结果
⌘I