图片生成
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-imagine-1.0",
"prompt": "雨夜的未来城市,写实摄影",
"size": "1024x1024",
"n": 1,
"response_format": "url",
"quality": "standard"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "grok-imagine-1.0",
"prompt": "雨夜的未来城市,写实摄影",
"size": "1024x1024",
"n": 1,
"response_format": "url",
"quality": "standard"
}
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({
model: 'grok-imagine-1.0',
prompt: '雨夜的未来城市,写实摄影',
size: '1024x1024',
n: 1,
response_format: 'url',
quality: 'standard'
})
};
fetch('https://api.tikway.ai/v1/images/generations', 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.tikway.ai/v1/images/generations",
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([
'model' => 'grok-imagine-1.0',
'prompt' => '雨夜的未来城市,写实摄影',
'size' => '1024x1024',
'n' => 1,
'response_format' => 'url',
'quality' => 'standard'
]),
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.tikway.ai/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\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.tikway.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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 \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1791878400,
"data": [
{
"url": "https://example.com/generated.png",
"index": 0
}
]
}Grok
图片生成
Grok 文生图使用 POST /v1/images/generations,使用 size 指定比例、quality 指定分辨率,n 为 1–4。此入口不接受参考图;需要修改图片时使用本系列保留的图片编辑接口。
POST
https://api.tikway.ai
/
v1
/
images
/
generations
图片生成
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-imagine-1.0",
"prompt": "雨夜的未来城市,写实摄影",
"size": "1024x1024",
"n": 1,
"response_format": "url",
"quality": "standard"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "grok-imagine-1.0",
"prompt": "雨夜的未来城市,写实摄影",
"size": "1024x1024",
"n": 1,
"response_format": "url",
"quality": "standard"
}
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({
model: 'grok-imagine-1.0',
prompt: '雨夜的未来城市,写实摄影',
size: '1024x1024',
n: 1,
response_format: 'url',
quality: 'standard'
})
};
fetch('https://api.tikway.ai/v1/images/generations', 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.tikway.ai/v1/images/generations",
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([
'model' => 'grok-imagine-1.0',
'prompt' => '雨夜的未来城市,写实摄影',
'size' => '1024x1024',
'n' => 1,
'response_format' => 'url',
'quality' => 'standard'
]),
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.tikway.ai/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\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.tikway.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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 \"model\": \"grok-imagine-1.0\",\n \"prompt\": \"雨夜的未来城市,写实摄影\",\n \"size\": \"1024x1024\",\n \"n\": 1,\n \"response_format\": \"url\",\n \"quality\": \"standard\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1791878400,
"data": [
{
"url": "https://example.com/generated.png",
"index": 0
}
]
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
Tikway 标准图片请求。
Minimum string length:
1必填。使用 Get Models 返回的模型 ID 或可用别名。
Minimum string length:
1示例:
"grok-imagine-1.0"
"grok-imagine-2.0"
"grok-imagine-image"
"grok-imagine-image-quality"
"grok-imagine-image-2.0"
Grok Pro 模式开关,仅支持该参数的模型可用。
生成图片数量,1–4。
必填范围:
1 <= x <= 4输出宽高比使用 WIDTHxHEIGHT 表示,例如 1024x1536 表示 2:3;auto 使用模型默认比例。分辨率由 quality 控制。
Pattern:
^(auto|[1-9][0-9]*x[1-9][0-9]*)$Tikway 图片交付格式,url 返回图片链接,b64_json 返回纯 Base64。默认 url;该字段由网关消费,不作为上游模型参数。
可用选项:
url, b64_json standard 输出 1K,hd 输出 2K;可用能力以所选模型为准。
可用选项:
standard, hd 参考图,1–5 张。不支持独立 mask 参数。
Required array length:
1 - 5 elementsMinimum string length:
1响应
200 - application/json
同步返回统一 Images 结果;response_format 决定返回 url 或 b64_json。
Unix 时间戳(秒)。
返回时为请求使用的模型 ID。

