Przejdź do głównej treści

Endpointy

MetodaEndpointOpis
POST/api/v1/generateTask/flux-kontextUtwórz zadanie generowania
GET/api/v1/statusTask/flux-kontextSprawdź status zadania

Uwierzytelnianie

Wszystkie żądania wymagają klucza API w nagłówku:
Authorization: Bearer YOUR_API_KEY

Treść żądania

{
  "request_type": "async",
  "callback_url": "https://...",
  "provider": "auto",
  "input": {
    "mode": "pro",
    "prompt": "...",
    "aspect_ratio": "16:9",
    "image_urls": ["..."],
    "output_format": "jpeg"
  }
}

Parametry

request_type
string
domyślnie:"async"
async (polling) or callback (webhook)
callback_url
string
Callback URL, required when request_type=callback (conditional)
provider
string
domyślnie:"auto"
Routing strategy: auto, value, or official
input
object
wymagane
Model input parameters
Mode Options:
  • pro — Higher quality, slower generation
  • max — Balanced quality and speed

Przykład

Text-to-Image
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-kontext" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "pro",
      "prompt": "a castle on the hill at sunset",
      "aspect_ratio": "16:9",
      "output_format": "jpeg"
    }
  }'
Image-to-Image (Style Transfer)
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-kontext" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "provider": "official",
    "input": {
      "mode": "max",
      "prompt": "transform this into a watercolor painting",
      "aspect_ratio": "16:9",
      "image_urls": ["https://example.com/ref.jpg"],
      "output_format": "png",
      "safetyTolerance": 2
    }
  }'

Odpowiedź

POST /api/v1/generateTask/flux-kontext

Returns taskId on success for subsequent status queries. Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Error:
{
  "code": 400,
  "message": "Insufficient credits",
  "data": null
}

GET /api/v1/statusTask/flux-kontext

Query task execution status and results via taskId.
curl -X GET "https://api.apixo.ai/api/v1/statusTask/flux-kontext?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/xxx.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Failed:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines"
  }
}

Pola odpowiedzi statusu

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing resultUrls array. Only present on success. Parse with JSON.parse().
failCode
string
Error code. Only present when state is failed. See Kody błędów.
failMsg
string
Human-readable error message. Only present when state is failed.
createTime
integer
Task creation timestamp (Unix milliseconds).
completeTime
integer
Task completion timestamp (Unix milliseconds).
costTime
integer
Processing duration in milliseconds.

Kody błędów

CodeDescription
400Invalid parameters or request error
401Invalid or missing API Key
429Rate limit exceeded
Fail CodeDescription
CONTENT_VIOLATIONContent violates safety guidelines
INVALID_IMAGE_URLCannot access provided image URL

Limity rate

LimitValue
Requests10000 / minute
Concurrent tasks1000
Exceeding limits returns 429 error. Wait and retry.

Wskazówki

  • Generation time: Average ~30 seconds. Submit task, wait 20 seconds, then poll every 3 seconds.
  • Callback mode: For high-concurrency scenarios, use callback mode to avoid frequent polling.
  • Image expiration: Result URLs are valid for 15 days. Download and store important outputs promptly.
  • Content moderation: Prompts must comply with content safety guidelines. Violations return CONTENT_VIOLATION.
  • Reference images: image_urls supports JPG, PNG, WebP formats, max 10MB per image.
  • Context understanding: Kontext mode excels at understanding reference image style and composition.
  • Mode selection: pro mode offers higher quality but slower speed; max balances quality and speed.

Result URLs expire after 15 days. Download and store important outputs promptly. For high-concurrency scenarios, use callback mode to avoid frequent polling.

Powiązane