# Fantase API > AI image and video generation API. REST endpoints with API-KEY header auth. Supports image-to-image, image-to-video, and image-to-audio+video generation. Base URL: https://api.fantaseai.com ## Authentication All requests require an `API-KEY` header. Get your key at https://fantaseai.com/dashboard. ## API Reference - [OpenAPI Spec (JSON)](https://api.fantaseai.com/api/openapi.json): Full machine-readable API schema. Requires API-KEY header. - [Interactive Docs (Swagger UI)](https://api.fantaseai.com/api/docs): Try endpoints in the browser. ## Endpoints ### POST /api/create_image Transform an image using AI. Returns a Task object. Request body: - `input_image_base64` (string, required): Base64-encoded input image. - `preset_name` (string, required): Transformation preset. Examples: `custom`, `tattoo`, `restyle`. See full list in OpenAPI spec. - `prompt` (string, optional): Custom prompt text. Used with `custom` preset or to override preset prompt. - `input_image2_base64` (string, optional): Second image for remix presets (e.g. `remix_dress`, `remix_yoga`). - `expand_prompt` (boolean, optional): Enable LLM-based prompt upsampling. ### POST /api/create_video Generate video from a single image. Returns a Task object. Request body: - `input_image_base64` (string, required): Base64-encoded input image. - `preset_name` (string, required): Motion preset. Examples: `custom`. See full list in OpenAPI spec. - `prompt` (string, optional): Custom prompt text. - `quality` (string, optional): `low`, `mid`, or `high`. Default: `low`. ### POST /api/create_audio_video Generate video with synchronized audio. Returns a Task object. Request body: - `input_image_base64` (string, required): Base64-encoded input image. - `preset_name` (string, required): Preset. See valid values in OpenAPI spec. - `prompt` (string, optional): Custom prompt text. - `quality` (string, optional): `low` or `mid`. Default: `low`. - `video_length` (string, optional): `5s`, `10s`, `15s`, or `20s`. Default: `5s`. ### GET /api/task/{task_id} Poll task status and retrieve output URL. Response fields: - `id` (string): Task ID. - `status` (string): `NEW`, `PROCESSING`, `COMPLETED`, `FAILED`, or `DOWNLOADED`. - `output_url` (string): Direct download URL when status is `COMPLETED` or `DOWNLOADED`. - `task_message` (string): Error message if status is `FAILED`. - `cost_amount` (string): USD cost charged for this task. ### GET /api/balance Check remaining USD balance. Response fields: - `symbol` (string): Always `USD`. - `available_amount` (string): Available balance. - `frozen_amount` (string): Amount frozen for in-progress tasks. ## Quickstart ```python import requests, base64, time API_KEY = "your_api_key" HEADERS = {"API-KEY": API_KEY} # 1. Encode image with open("input.jpg", "rb") as f: img_b64 = base64.b64encode(f.read()).decode() # 2. Create task resp = requests.post( "https://api.fantaseai.com/api/create_video", headers=HEADERS, json={"input_image_base64": img_b64, "preset_name": "custom", "quality": "high"} ) task_id = resp.json()["id"] # 3. Poll until complete while True: result = requests.get(f"https://api.fantaseai.com/api/task/{task_id}", headers=HEADERS).json() if result["status"] in ("COMPLETED", "DOWNLOADED"): print(result["output_url"]) break elif result["status"] == "FAILED": print("Failed:", result["task_message"]) break time.sleep(3) ``` ## Resources - [API Console / Dashboard](https://fantaseai.com/dashboard): Manage API key, balance, and deposits. - [OpenAPI Spec](https://api.fantaseai.com/api/openapi.json): Machine-readable schema (requires API-KEY header). ## Optional - [Support (Telegram)](https://telegram.me/Michael_Voss): Volume discounts, custom pricing, technical help.