Grok Imagine API
xAI의 Grok Imagine 이미지 생성 모델에 대한 완전한 API 참조 문서입니다.
모델 변형
이 API는 두 가지 모델 변형을 지원합니다:
빠른 비교
Grok Imagine (텍스트-이미지)
엔드포인트 {#}
POST /api/v1/image/task
요청 파라미터
필수
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'grok-imagine',
prompt: 'A surreal landscape with floating islands and waterfalls',
width: 16,
height: 9
})
});
const { data } = await response.json();
const taskId = data.task_id;
const pollResponse = await fetch(
`https://api.flaq.ai/api/v1/image/${taskId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const result = await pollResponse.json();
console.log(result.data.task_result.images[0].url);
Grok Imagine Edit (이미지 편집)
요청 파라미터
필수
요청 예시
{
model_name: 'grok-imagine-edit',
width: 1,
height: 1,
image_url_list: ['https://example.com/photo.jpg'],
prompt: 'Change the sky to a dramatic sunset with orange and purple hues'
}
응답 형식
초기 응답
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "submitted",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}"
},
"message": "success"
}
폴링 응답
GET /api/v1/image/{task_id}를 폴링하여 상태를 확인합니다:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_result": {
"credit": 0.0997,
"images": [
{
"url": "https://example.com/generated-image.jpeg"
}
]
}
},
"message": "success"
}
상태 값
submitted: 작업이 접수되었습니다
processing: 이미지 생성 진행 중
succeed: 이미지 생성 완료
failed: 이미지 생성 실패
처리 시간
일반적인 처리 시간: 15-60초.
모범 사례
- 창의적인 프롬프트: Grok Imagine은 상상력이 풍부하고 상세한 설명에 잘 반응합니다
- 편집 구체성: 편집의 경우 변경할 내용과 보존할 내용을 명확하게 설명하세요