openapi: 3.2.0 info: title: Magic Hour Image Projects API version: beta description: "\nMagic Hour provides an API (beta) that can be integrated into your own application to generate videos and images using AI. \n\nWebhook documentation can be found [here](https://docs.magichour.ai/webhook-reference).\n\nIf you have any questions, please reach out to us via [discord](https://discord.gg/JX5rgsZaJp).\n\n# Authentication\n\nEvery request requires an API key.\n\nTo get started, first generate your API key [here](https://magichour.ai/developer?tab=api-keys&utm_source=docs&utm_medium=referral&utm_campaign=api-reference).\n\nThen, add the `Authorization` header to the request.\n\n| Key | Value |\n|-|-|\n| Authorization | Bearer mhk_live_apikey |\n\n> **Warning**: any API call that renders a video will utilize credits in your account.\n" termsOfService: https://magichour.ai/terms-of-service servers: - url: https://api.magichour.ai tags: - name: Image Projects description: API related to image projects paths: /v1/image-projects/{id}: get: description: "Check the progress of a image project. The `downloads` field is populated after a successful render.\n \n**Statuses**\n- `queued` — waiting to start\n- `rendering` — in progress\n- `complete` — ready; see `downloads`\n- `error` — a failure occurred (see `error`)\n- `canceled` — user canceled\n- `draft` — not used" summary: Get image details tags: - Image Projects parameters: - name: id in: path required: true schema: type: string example: cuid-example description: Unique ID of the image project. This value is returned by all of the POST APIs that create an image. operationId: imageProjects.getDetails responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. name: type: - string - 'null' description: The name of the image. example: Example Name status: type: string enum: - draft - queued - rendering - complete - error - canceled description: 'The status of the image. - `draft` - the project was created but has not been submitted for rendering - `queued` - the job is waiting for an available server - `rendering` - the job is being processed; the `image.started` webhook event fires when rendering begins - `complete` - the job finished successfully; fires `image.completed` - `error` - the job failed during processing; fires `image.errored` - `canceled` - the job was manually canceled (for example from the Magic Hour web app) **Note:** `rendering`, `complete`, and `error` have matching webhook events; `canceled` does not - a canceled job emits no webhook event, so poll this endpoint to detect cancellation.' example: complete image_count: type: integer description: Number of images generated example: 1 type: type: string description: The type of the image project. Possible values are FACE_EDITOR, AI_IMAGE_EDITOR, AI_SELFIE, AI_HEADSHOT, AI_INFLUENCER, AI_IMAGE, AI_MEME, CLOTHES_CHANGER, BACKGROUND_REMOVER, FACE_SWAP, IMAGE_UPSCALER, IMAGE_ENHANCER, AI_GIF, QR_CODE, PHOTO_EDITOR, PHOTO_COLORIZER, HEAD_SWAP, BODY_SWAP, STORYBOARD, IMAGE_EXPANDER example: AI_IMAGE created_at: type: string format: date-time enabled: type: boolean description: Whether this resource is active. If false, it is deleted. credits_charged: type: integer example: 5 description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." downloads: type: array items: type: object properties: url: type: string format: uri example: https://videos.magichour.ai/id/output.png expires_at: type: string format: date-time example: '2024-10-19T05:16:19.027Z' required: - url - expires_at description: The download url and expiration date of the image project error: type: - object - 'null' properties: message: type: string description: Details on the reason why a failure happened. example: Please use an image with a detectable face code: type: string example: no_source_face description: An error code to indicate why a failure happened. required: - message - code description: In the case of an error, this object will contain the error encountered during video render example: null required: - id - name - status - image_count - type - created_at - enabled - credits_charged - downloads - error description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found security: - bearerAuth: [] x-codeSamples: - lang: python source: 'from magic_hour import Client from os import getenv client = Client(token=getenv("API_TOKEN")) res = client.v1.image_projects.get(id="cuid-example")' - lang: javascript source: 'import { Client } from "magic-hour"; const client = new Client({ token: process.env["API_TOKEN"]!! }); const res = await client.v1.imageProjects.get({ id: "cuid-example" });' - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\timage_projects \"github.com/magichourhq/magic-hour-go/resources/v1/image_projects\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.ImageProjects.Get(image_projects.GetRequest{\n\t\tId: \"cuid-example\",\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .image_projects()\n .get(magic_hour::resources::v1::image_projects::GetRequest {\n id: \"cuid-example\".to_string(),\n })\n .await;" - lang: curl source: "curl --request GET \\\n --url https://api.magichour.ai/v1/image-projects/id \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer '" - lang: php source: " \"https://api.magichour.ai/v1/image-projects/id\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"GET\",\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.get(\"https://api.magichour.ai/v1/image-projects/id\")\n .header(\"accept\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .asString();" delete: description: Permanently delete the rendered image(s). This action is not reversible, please be sure before deleting. summary: Delete image tags: - Image Projects parameters: - name: id in: path required: true schema: type: string example: cuid-example description: Unique ID of the image project. This value is returned by all of the POST APIs that create an image. operationId: imageProjects.delete responses: '204': description: '204' '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found security: - bearerAuth: [] x-codeSamples: - lang: python source: 'from magic_hour import Client from os import getenv client = Client(token=getenv("API_TOKEN")) res = client.v1.image_projects.delete(id="cuid-example")' - lang: javascript source: 'import { Client } from "magic-hour"; const client = new Client({ token: process.env["API_TOKEN"]!! }); const res = await client.v1.imageProjects.delete({ id: "cuid-example" });' - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\timage_projects \"github.com/magichourhq/magic-hour-go/resources/v1/image_projects\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\terr := client.V1.ImageProjects.Delete(image_projects.DeleteRequest{\n\t\tId: \"cuid-example\",\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .image_projects()\n .delete(magic_hour::resources::v1::image_projects::DeleteRequest {\n id: \"cuid-example\".to_string(),\n })\n .await;" - lang: curl source: "curl --request DELETE \\\n --url https://api.magichour.ai/v1/image-projects/id \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer '" - lang: php source: " \"https://api.magichour.ai/v1/image-projects/id\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"DELETE\",\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.delete(\"https://api.magichour.ai/v1/image-projects/id\")\n .header(\"accept\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .asString();" /v1/ai-clothes-changer: post: description: Change outfits in photos in seconds with just a photo reference. Each photo costs 25 credits. summary: AI Clothes Changer tags: - Image Projects parameters: [] operationId: aiClothesChanger.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Clothes Changer image default: Clothes Changer - dateTime assets: type: object properties: person_file_path: type: string minLength: 1 description: 'The image with the person. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/model.png garment_file_path: type: string minLength: 1 description: 'The image of the outfit. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/outfit.png garment_type: type: string enum: - entire_outfit - upper_body - lower_body - dresses description: "Type of garment to swap. If not provided, swaps the entire outfit. \n* `upper_body` - for shirts/jackets \n* `lower_body` - for pants/skirts \n* `dresses` - for entire outfit (deprecated, use `entire_outfit` instead) \n* `entire_outfit` - for entire outfit" example: entire_outfit required: - person_file_path - garment_file_path description: Provide the assets for clothes changer required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 25 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_clothes_changer.generate(\n assets={\n \"garment_file_path\": \"/path/to/outfit.png\",\n \"garment_type\": \"upper_body\",\n \"person_file_path\": \"/path/to/model.png\",\n },\n name=\"Clothes Changer image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\",\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiClothesChanger.generate(\n {\n assets: {\n garmentFilePath: \"/path/to/outfit.png\",\n garmentType: \"upper_body\",\n personFilePath: \"/path/to/model.png\",\n },\n name: \"Clothes Changer image\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_clothes_changer \"github.com/magichourhq/magic-hour-go/resources/v1/ai_clothes_changer\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiClothesChanger.Create(ai_clothes_changer.CreateRequest{\n\t\tAssets: types.V1AiClothesChangerCreateBodyAssets{\n\t\t\tGarmentFilePath: \"api-assets/id/outfit.png\",\n\t\t\tGarmentType: nullable.NewValue(types.V1AiClothesChangerCreateBodyAssetsGarmentTypeEnumEntireOutfit),\n\t\t\tPersonFilePath: \"api-assets/id/model.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Clothes Changer image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_clothes_changer()\n .create(magic_hour::resources::v1::ai_clothes_changer::CreateRequest {\n assets: magic_hour::models::V1AiClothesChangerCreateBodyAssets {\n garment_file_path: \"api-assets/id/outfit.png\".to_string(),\n garment_type: Some(\n magic_hour::models::V1AiClothesChangerCreateBodyAssetsGarmentTypeEnum::EntireOutfit,\n ),\n person_file_path: \"api-assets/id/model.png\".to_string(),\n },\n name: Some(\"My Clothes Changer image\".to_string()),\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-clothes-changer \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Clothes Changer image\",\n \"assets\": {\n \"person_file_path\": \"api-assets/id/model.png\",\n \"garment_file_path\": \"api-assets/id/outfit.png\",\n \"garment_type\": \"entire_outfit\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-clothes-changer\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Clothes Changer image',\n 'assets' => [\n 'person_file_path' => 'api-assets/id/model.png',\n 'garment_file_path' => 'api-assets/id/outfit.png',\n 'garment_type' => 'entire_outfit'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-clothes-changer\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Clothes Changer image\\\",\\\"assets\\\":{\\\"person_file_path\\\":\\\"api-assets/id/model.png\\\",\\\"garment_file_path\\\":\\\"api-assets/id/outfit.png\\\",\\\"garment_type\\\":\\\"entire_outfit\\\"}}\")\n .asString();" /v1/ai-face-editor: post: description: Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](https://magichour.ai/pricing) page for more details summary: AI Face Editor tags: - Image Projects parameters: [] operationId: aiFaceEditor.editImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Face Editor image default: Face Editor - dateTime assets: type: object properties: image_file_path: type: string minLength: 1 description: 'This is the image whose face will be edited. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - image_file_path description: Provide the assets for face editor style: type: object properties: enhance_face: default: false type: boolean description: Enhance face features example: false eyebrow_direction: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Eyebrow direction (-100 to 100), in increments of 5 example: 0 eye_gaze_horizontal: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Horizontal eye gaze (-100 to 100), in increments of 5 example: 0 eye_gaze_vertical: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Vertical eye gaze (-100 to 100), in increments of 5 example: 0 eye_open_ratio: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Eye open ratio (-100 to 100), in increments of 5 example: 0 lip_open_ratio: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Lip open ratio (-100 to 100), in increments of 5 example: 0 head_roll: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Head roll (-100 to 100), in increments of 5 example: 0 mouth_grim: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Mouth grim (-100 to 100), in increments of 5 example: 0 mouth_pout: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Mouth pout (-100 to 100), in increments of 5 example: 0 mouth_purse: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Mouth purse (-100 to 100), in increments of 5 example: 0 mouth_smile: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Mouth smile (-100 to 100), in increments of 5 example: 0 mouth_position_horizontal: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Horizontal mouth position (-100 to 100), in increments of 5 example: 0 mouth_position_vertical: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Vertical mouth position (-100 to 100), in increments of 5 example: 0 head_pitch: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Head pitch (-100 to 100), in increments of 5 example: 0 head_yaw: default: 0 type: number minimum: -100 maximum: 100 multipleOf: 5 description: Head yaw (-100 to 100), in increments of 5 example: 0 description: Face editing parameters required: - assets - style responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 1 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_face_editor.generate(\n assets={\"image_file_path\": \"/path/to/1234.png\"},\n style={\n \"enhance_face\": False,\n \"eye_gaze_horizontal\": 0.0,\n \"eye_gaze_vertical\": 0.0,\n \"eye_open_ratio\": 0.0,\n \"eyebrow_direction\": 0.0,\n \"head_pitch\": 0.0,\n \"head_roll\": 0.0,\n \"head_yaw\": 0.0,\n \"lip_open_ratio\": 0.0,\n \"mouth_grim\": 0.0,\n \"mouth_position_horizontal\": 0.0,\n \"mouth_position_vertical\": 0.0,\n \"mouth_pout\": 0.0,\n \"mouth_purse\": 0.0,\n \"mouth_smile\": 0.0,\n },\n name=\"Face Editor image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiFaceEditor.generate(\n {\n assets: { imageFilePath: \"/path/to/1234.png\" },\n name: \"Face Editor image\",\n style: {\n enhanceFace: false,\n eyeGazeHorizontal: 0.0,\n eyeGazeVertical: 0.0,\n eyeOpenRatio: 0.0,\n eyebrowDirection: 0.0,\n headPitch: 0.0,\n headRoll: 0.0,\n headYaw: 0.0,\n lipOpenRatio: 0.0,\n mouthGrim: 0.0,\n mouthPositionHorizontal: 0.0,\n mouthPositionVertical: 0.0,\n mouthPout: 0.0,\n mouthPurse: 0.0,\n mouthSmile: 0.0,\n },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_face_editor \"github.com/magichourhq/magic-hour-go/resources/v1/ai_face_editor\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiFaceEditor.Create(ai_face_editor.CreateRequest{\n\t\tAssets: types.V1AiFaceEditorCreateBodyAssets{\n\t\t\tImageFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Face Editor image\"),\n\t\tStyle: types.V1AiFaceEditorCreateBodyStyle{\n\t\t\tEnhanceFace: nullable.NewValue(false),\n\t\t\tEyeGazeHorizontal: nullable.NewValue(0.0),\n\t\t\tEyeGazeVertical: nullable.NewValue(0.0),\n\t\t\tEyeOpenRatio: nullable.NewValue(0.0),\n\t\t\tEyebrowDirection: nullable.NewValue(0.0),\n\t\t\tHeadPitch: nullable.NewValue(0.0),\n\t\t\tHeadRoll: nullable.NewValue(0.0),\n\t\t\tHeadYaw: nullable.NewValue(0.0),\n\t\t\tLipOpenRatio: nullable.NewValue(0.0),\n\t\t\tMouthGrim: nullable.NewValue(0.0),\n\t\t\tMouthPositionHorizontal: nullable.NewValue(0.0),\n\t\t\tMouthPositionVertical: nullable.NewValue(0.0),\n\t\t\tMouthPout: nullable.NewValue(0.0),\n\t\t\tMouthPurse: nullable.NewValue(0.0),\n\t\t\tMouthSmile: nullable.NewValue(0.0),\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_face_editor()\n .create(magic_hour::resources::v1::ai_face_editor::CreateRequest {\n assets: magic_hour::models::V1AiFaceEditorCreateBodyAssets {\n image_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Face Editor image\".to_string()),\n style: magic_hour::models::V1AiFaceEditorCreateBodyStyle {\n enhance_face: Some(false),\n eye_gaze_horizontal: Some(0.0),\n eye_gaze_vertical: Some(0.0),\n eye_open_ratio: Some(0.0),\n eyebrow_direction: Some(0.0),\n head_pitch: Some(0.0),\n head_roll: Some(0.0),\n head_yaw: Some(0.0),\n lip_open_ratio: Some(0.0),\n mouth_grim: Some(0.0),\n mouth_position_horizontal: Some(0.0),\n mouth_position_vertical: Some(0.0),\n mouth_pout: Some(0.0),\n mouth_purse: Some(0.0),\n mouth_smile: Some(0.0),\n },\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-face-editor \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Face Editor image\",\n \"assets\": {\n \"image_file_path\": \"api-assets/id/1234.png\"\n },\n \"style\": {\n \"enhance_face\": false,\n \"eyebrow_direction\": 0,\n \"eye_gaze_horizontal\": 0,\n \"eye_gaze_vertical\": 0,\n \"eye_open_ratio\": 0,\n \"lip_open_ratio\": 0,\n \"head_roll\": 0,\n \"mouth_grim\": 0,\n \"mouth_pout\": 0,\n \"mouth_purse\": 0,\n \"mouth_smile\": 0,\n \"mouth_position_horizontal\": 0,\n \"mouth_position_vertical\": 0,\n \"head_pitch\": 0,\n \"head_yaw\": 0\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-face-editor\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Face Editor image',\n 'assets' => [\n 'image_file_path' => 'api-assets/id/1234.png'\n ],\n 'style' => [\n 'enhance_face' => false,\n 'eyebrow_direction' => 0,\n 'eye_gaze_horizontal' => 0,\n 'eye_gaze_vertical' => 0,\n 'eye_open_ratio' => 0,\n 'lip_open_ratio' => 0,\n 'head_roll' => 0,\n 'mouth_grim' => 0,\n 'mouth_pout' => 0,\n 'mouth_purse' => 0,\n 'mouth_smile' => 0,\n 'mouth_position_horizontal' => 0,\n 'mouth_position_vertical' => 0,\n 'head_pitch' => 0,\n 'head_yaw' => 0\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-face-editor\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Face Editor image\\\",\\\"assets\\\":{\\\"image_file_path\\\":\\\"api-assets/id/1234.png\\\"},\\\"style\\\":{\\\"enhance_face\\\":false,\\\"eyebrow_direction\\\":0,\\\"eye_gaze_horizontal\\\":0,\\\"eye_gaze_vertical\\\":0,\\\"eye_open_ratio\\\":0,\\\"lip_open_ratio\\\":0,\\\"head_roll\\\":0,\\\"mouth_grim\\\":0,\\\"mouth_pout\\\":0,\\\"mouth_purse\\\":0,\\\"mouth_smile\\\":0,\\\"mouth_position_horizontal\\\":0,\\\"mouth_position_vertical\\\":0,\\\"head_pitch\\\":0,\\\"head_yaw\\\":0}}\")\n .asString();" /v1/ai-gif-generator: post: description: Create an AI GIF. Each GIF costs 50 credits. summary: AI GIF Generator tags: - Image Projects parameters: [] operationId: aiGifGenerator.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your gif a custom name for easy identification. example: My Ai Gif gif default: Ai Gif - dateTime style: type: object properties: prompt: type: string minLength: 1 maxLength: 500 description: The prompt used for the GIF. example: Cute dancing cat, pixel art required: - prompt output_format: default: gif type: string enum: - gif - mp4 - webm description: The output file format for the generated animation. example: gif required: - style responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 50 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create GIF required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_gif_generator.generate(\n style={\"prompt\": \"Cute dancing cat, pixel art\"},\n name=\"Ai Gif gif\",\n output_format=\"gif\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiGifGenerator.generate(\n {\n name: \"Ai Gif gif\",\n style: { prompt: \"Cute dancing cat, pixel art\" },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_gif_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_gif_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiGifGenerator.Create(ai_gif_generator.CreateRequest{\n\t\tName: nullable.NewValue(\"My Ai Gif gif\"),\n\t\tOutputFormat: nullable.NewValue(types.V1AiGifGeneratorCreateBodyOutputFormatEnumGif),\n\t\tStyle: types.V1AiGifGeneratorCreateBodyStyle{\n\t\t\tPrompt: \"Cute dancing cat, pixel art\",\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_gif_generator()\n .create(magic_hour::resources::v1::ai_gif_generator::CreateRequest {\n name: Some(\"My Ai Gif gif\".to_string()),\n output_format: Some(\n magic_hour::models::V1AiGifGeneratorCreateBodyOutputFormatEnum::Gif,\n ),\n style: magic_hour::models::V1AiGifGeneratorCreateBodyStyle {\n prompt: \"Cute dancing cat, pixel art\".to_string(),\n },\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-gif-generator \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Ai Gif gif\",\n \"style\": {\n \"prompt\": \"Cute dancing cat, pixel art\"\n },\n \"output_format\": \"gif\"\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-gif-generator\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Ai Gif gif',\n 'style' => [\n 'prompt' => 'Cute dancing cat, pixel art'\n ],\n 'output_format' => 'gif'\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-gif-generator\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Ai Gif gif\\\",\\\"style\\\":{\\\"prompt\\\":\\\"Cute dancing cat, pixel art\\\"},\\\"output_format\\\":\\\"gif\\\"}\")\n .asString();" /v1/ai-image-editor: post: description: Edit images with AI. summary: AI Image Editor tags: - Image Projects parameters: [] operationId: aiImageEditor.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Ai Image Editor image default: Ai Image Editor - dateTime image_count: type: number enum: - 1 - 4 - 9 - 16 description: Number of images to generate. Maximum varies by model. Defaults to 1 if not specified. example: 1 default: 1 model: type: string enum: - default - nano-banana-2 - gpt-image-2 - flux-2-klein - nano-banana-2-lite - qwen-edit - seedream-v4 - seedream-v4.5 - seedream-v5-pro - nano-banana - nano-banana-pro description: "The AI model to use for image editing. Each model has different capabilities and costs.\n\n**Models:**\n- `default` - Use the model we recommend, which will change over time. This is recommended unless you need a specific model. This is the default behavior.\n- `flux-2-klein` - from 5 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: free, creator, pro, business\n - Max additional input images: 5\n- `gpt-image-2` - from 50 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `nano-banana` - from 50 credits/image\n - Supported resolutions: 640px, 1k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `nano-banana-2` - from 100 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `nano-banana-2-lite` - from 50 credits/image\n - Supported resolutions: 640px, 1k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `nano-banana-pro` - from 150 credits/image\n - Supported resolutions: 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `qwen-edit` - from 10 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: free, creator, pro, business\n - Max additional input images: 2\n- `seedream-v4` - from 40 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `seedream-v4.5` - from 50 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n- `seedream-v5-pro` - from 75 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: creator, pro, business\n - Max additional input images: 9\n" example: default aspect_ratio: type: string enum: - auto - '16:9' - '9:16' - '4:3' - '3:2' - '1:1' - '4:5' - '2:3' description: The aspect ratio of the output image(s). If not specified, defaults to `auto`. example: '1:1' resolution: type: string enum: - auto - 640px - 1k - 2k - 4k description: 'Maximum resolution (longest edge) for the output image. **Options:** - `640px` — up to 640px - `1k` — up to 1024px - `2k` — up to 2048px - `4k` — up to 4096px - `auto` — **Deprecated.** Mapped server-side from your subscription tier to the best matching resolution the model supports **Per-model support:** - `flux-2-klein` - 640px, 1k, 2k - `gpt-image-2` - 640px, 1k, 2k, 4k - `nano-banana` - 640px, 1k - `nano-banana-2` - 640px, 1k, 2k, 4k - `nano-banana-2-lite` - 640px, 1k - `nano-banana-pro` - 1k, 2k, 4k - `qwen-edit` - 640px, 1k, 2k - `seedream-v4` - 640px, 1k, 2k, 4k - `seedream-v4.5` - 640px, 1k, 2k, 4k - `seedream-v5-pro` - 640px, 1k, 2k Note: Resolution availability depends on the model and your subscription tier.' example: 1k style: type: object properties: prompt: type: string minLength: 1 maxLength: 15000 description: The prompt used to edit the image. example: Give me sunglasses required: - prompt assets: type: object properties: image_file_paths: type: array items: type: string minLength: 1 maxItems: 10 description: 'The image(s) used in the edit, maximum of 10 images. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: - api-assets/id/1234.png - api-assets/id/1235.png description: Provide the assets for image edit required: - style - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 50 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to edit image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_image_editor.generate(\n assets={\"image_file_paths\": [\"/path/to/1234.png\"]},\n style={\"prompt\": \"Give me sunglasses\"},\n name=\"Ai Image Editor image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiImageEditor.generate(\n {\n assets: { imageFilePaths: [\"/path/to/1234.png\", \"/path/to/1235.png\"] },\n name: \"Ai Image Editor image\",\n style: { prompt: \"Give me sunglasses\" },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_image_editor \"github.com/magichourhq/magic-hour-go/resources/v1/ai_image_editor\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiImageEditor.Create(ai_image_editor.CreateRequest{\n\t\tAspectRatio: nullable.NewValue(types.V1AiImageEditorCreateBodyAspectRatioEnum11),\n\t\tAssets: types.V1AiImageEditorCreateBodyAssets{\n\t\t\tImageFilePaths: nullable.NewValue([]string{\n\t\t\t\t\"api-assets/id/1234.png\",\n\t\t\t\t\"api-assets/id/1235.png\",\n\t\t\t}),\n\t\t},\n\t\tImageCount: nullable.NewValue(1.0),\n\t\tModel: nullable.NewValue(types.V1AiImageEditorCreateBodyModelEnumDefault),\n\t\tName: nullable.NewValue(\"My Ai Image Editor image\"),\n\t\tResolution: nullable.NewValue(types.V1AiImageEditorCreateBodyResolutionEnum1k),\n\t\tStyle: types.V1AiImageEditorCreateBodyStyle{\n\t\t\tPrompt: \"Give me sunglasses\",\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_image_editor()\n .create(magic_hour::resources::v1::ai_image_editor::CreateRequest {\n aspect_ratio: Some(\n magic_hour::models::V1AiImageEditorCreateBodyAspectRatioEnum::Enum11,\n ),\n assets: magic_hour::models::V1AiImageEditorCreateBodyAssets {\n image_file_paths: Some(\n vec![\n \"api-assets/id/1234.png\".to_string(), \"api-assets/id/1235.png\"\n .to_string()\n ],\n ),\n ..Default::default()\n },\n image_count: Some(1.0),\n model: Some(magic_hour::models::V1AiImageEditorCreateBodyModelEnum::Default),\n name: Some(\"My Ai Image Editor image\".to_string()),\n resolution: Some(\n magic_hour::models::V1AiImageEditorCreateBodyResolutionEnum::Enum1k,\n ),\n style: magic_hour::models::V1AiImageEditorCreateBodyStyle {\n prompt: \"Give me sunglasses\".to_string(),\n ..Default::default()\n },\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-image-editor \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Ai Image Editor image\",\n \"image_count\": 1,\n \"model\": \"default\",\n \"aspect_ratio\": \"1:1\",\n \"resolution\": \"1k\",\n \"style\": {\n \"prompt\": \"Give me sunglasses\"\n },\n \"assets\": {\n \"image_file_paths\": [\n \"api-assets/id/1234.png\",\n \"api-assets/id/1235.png\"\n ]\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-image-editor\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Ai Image Editor image',\n 'image_count' => 1,\n 'model' => 'default',\n 'aspect_ratio' => '1:1',\n 'resolution' => '1k',\n 'style' => [\n 'prompt' => 'Give me sunglasses'\n ],\n 'assets' => [\n 'image_file_paths' => [\n 'api-assets/id/1234.png',\n 'api-assets/id/1235.png'\n ]\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-image-editor\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Ai Image Editor image\\\",\\\"image_count\\\":1,\\\"model\\\":\\\"default\\\",\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"resolution\\\":\\\"1k\\\",\\\"style\\\":{\\\"prompt\\\":\\\"Give me sunglasses\\\"},\\\"assets\\\":{\\\"image_file_paths\\\":[\\\"api-assets/id/1234.png\\\",\\\"api-assets/id/1235.png\\\"]}}\")\n .asString();" /v1/ai-headshot-generator: post: description: Create an AI headshot. Each headshot costs 50 credits. summary: AI Headshot Generator tags: - Image Projects parameters: [] operationId: aiHeadshotGenerator.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Ai Headshot image default: Ai Headshot - dateTime style: type: object properties: prompt: type: string description: Prompt used to guide the style of your headshot. We recommend omitting the prompt unless you want to customize your headshot. You can visit [AI headshot generator](https://magichour.ai/create/ai-headshot-generator) to view an example of a good prompt used for our 'Professional' style. assets: type: object properties: image_file_path: type: string minLength: 1 description: 'The image used to generate the headshot. This image must contain one detectable face. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - image_file_path description: Provide the assets for headshot photo required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 50 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_headshot_generator.generate(\n assets={\"image_file_path\": \"/path/to/1234.png\"}, name=\"Ai Headshot image\"\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiHeadshotGenerator.generate(\n {\n assets: { imageFilePath: \"/path/to/1234.png\" },\n name: \"Ai Headshot image\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_headshot_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_headshot_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiHeadshotGenerator.Create(ai_headshot_generator.CreateRequest{\n\t\tAssets: types.V1AiHeadshotGeneratorCreateBodyAssets{\n\t\t\tImageFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Ai Headshot image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_headshot_generator()\n .create(magic_hour::resources::v1::ai_headshot_generator::CreateRequest {\n assets: magic_hour::models::V1AiHeadshotGeneratorCreateBodyAssets {\n image_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Ai Headshot image\".to_string()),\n ..Default::default()\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-headshot-generator \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Ai Headshot image\",\n \"style\": {\n \"prompt\": \"string\"\n },\n \"assets\": {\n \"image_file_path\": \"api-assets/id/1234.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-headshot-generator\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Ai Headshot image',\n 'style' => [\n 'prompt' => 'string'\n ],\n 'assets' => [\n 'image_file_path' => 'api-assets/id/1234.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-headshot-generator\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Ai Headshot image\\\",\\\"style\\\":{\\\"prompt\\\":\\\"string\\\"},\\\"assets\\\":{\\\"image_file_path\\\":\\\"api-assets/id/1234.png\\\"}}\")\n .asString();" /v1/ai-image-generator: post: description: Create an AI image with advanced model selection and quality controls. summary: AI Image Generator tags: - Image Projects parameters: [] operationId: aiImageGenerator.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Ai Image image default: Ai Image - dateTime image_count: type: integer minimum: 1 maximum: 16 description: Number of images to generate. Maximum varies by model. example: 1 model: type: string enum: - default - nano-banana-2 - gpt-image-2 - z-image-turbo - flux-2-klein - nano-banana-2-lite - seedream-v4 - seedream-v5-pro - nano-banana - nano-banana-pro - flux-schnell - seedream description: "The AI model to use for image generation. Each model has different capabilities and costs.\n\n**Models:**\n- `default` - Use the model we recommend, which will change over time. This is recommended unless you need a specific model. This is the default behavior.\n- `flux-2-klein` - from 5 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: free, creator, pro, business\n - Image count allowed: 1\n- `flux-schnell` - from 5 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: free, creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `gpt-image-2` - from 50 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `nano-banana` - from 50 credits/image\n - Supported resolutions: 640px, 1k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `nano-banana-2` - from 100 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 4, 9, 16\n- `nano-banana-2-lite` - from 50 credits/image\n - Supported resolutions: 640px, 1k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `nano-banana-pro` - from 150 credits/image\n - Supported resolutions: 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 4, 9, 16\n- `seedream-v4` - from 40 credits/image\n - Supported resolutions: 640px, 1k, 2k, 4k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `seedream-v5-pro` - from 75 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n- `z-image-turbo` - from 5 credits/image\n - Supported resolutions: 640px, 1k, 2k\n - Available for tiers: free, creator, pro, business\n - Image count allowed: 1, 2, 3, 4\n\n**Deprecated Enum Values:**\n- `seedream` - Use `seedream-v4` instead.\n" example: default aspect_ratio: type: string enum: - '1:1' - '16:9' - '9:16' description: The aspect ratio of the output image(s). If not specified, defaults to `1:1` (square). example: '1:1' resolution: default: auto type: string enum: - auto - 640px - 1k - 2k - 4k description: 'Maximum resolution (longest edge) for the output image. **Options:** - `640px` — up to 640px - `1k` — up to 1024px - `2k` — up to 2048px - `4k` — up to 4096px - `auto` — **Deprecated.** Mapped server-side from your subscription tier to the best matching resolution the model supports **Per-model support:** - `flux-2-klein` - 640px, 1k, 2k - `flux-schnell` - 640px, 1k, 2k - `gpt-image-2` - 640px, 1k, 2k, 4k - `nano-banana` - 640px, 1k - `nano-banana-2` - 640px, 1k, 2k, 4k - `nano-banana-2-lite` - 640px, 1k - `nano-banana-pro` - 1k, 2k, 4k - `seedream-v4` - 640px, 1k, 2k, 4k - `seedream-v5-pro` - 640px, 1k, 2k - `z-image-turbo` - 640px, 1k, 2k Note: Resolution availability depends on the model and your subscription tier.' example: auto style: type: object properties: prompt: type: string minLength: 1 description: The prompt used for the image(s). example: Cool image tool: default: general type: string enum: - ai-anime-generator - ai-art-generator - ai-background-generator - ai-character-generator - ai-face-generator - ai-fashion-generator - ai-icon-generator - ai-illustration-generator - ai-interior-design-generator - ai-landscape-generator - ai-logo-generator - ai-manga-generator - ai-outfit-generator - ai-pattern-generator - ai-photo-generator - ai-sketch-generator - ai-tattoo-generator - album-cover-generator - animated-characters-generator - architecture-generator - book-cover-generator - comic-book-generator - dark-fantasy-ai - disney-ai-generator - dnd-ai-art-generator - emoji-generator - fantasy-map-generator - graffiti-generator - movie-poster-generator - optical-illusion-generator - pokemon-generator - south-park-character-generator - superhero-generator - thumbnail-maker - general description: The art style to use for image generation. Defaults to 'general' if not provided. example: ai-anime-generator required: - prompt description: The art style to use for image generation. required: - image_count - style responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 5 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_image_generator.generate(\n image_count=1,\n style={\n \"prompt\": \"Cool image\",\n \"tool\": \"ai-anime-generator\",\n },\n aspect_ratio=\"1:1\",\n model=\"default\",\n name=\"My Ai Image image\",\n resolution=\"auto\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiImageGenerator.generate(\n {\n aspectRatio: \"1:1\",\n imageCount: 1,\n model: \"default\",\n name: \"My Ai Image image\",\n resolution: \"auto\",\n style: { prompt: \"Cool image\", tool: \"ai-anime-generator\" },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_image_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_image_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiImageGenerator.Create(ai_image_generator.CreateRequest{\n\t\tAspectRatio: nullable.NewValue(types.V1AiImageGeneratorCreateBodyAspectRatioEnum11),\n\t\tImageCount: 1,\n\t\tModel: nullable.NewValue(types.V1AiImageGeneratorCreateBodyModelEnumDefault),\n\t\tName: nullable.NewValue(\"My Ai Image image\"),\n\t\tResolution: nullable.NewValue(types.V1AiImageGeneratorCreateBodyResolutionEnumAuto),\n\t\tStyle: types.V1AiImageGeneratorCreateBodyStyle{\n\t\t\tPrompt: \"Cool image\",\n\t\t\tTool: nullable.NewValue(types.V1AiImageGeneratorCreateBodyStyleToolEnumAiAnimeGenerator),\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_image_generator()\n .create(magic_hour::resources::v1::ai_image_generator::CreateRequest {\n aspect_ratio: Some(\n magic_hour::models::V1AiImageGeneratorCreateBodyAspectRatioEnum::Enum11,\n ),\n image_count: 1,\n model: Some(\n magic_hour::models::V1AiImageGeneratorCreateBodyModelEnum::Default,\n ),\n name: Some(\"My Ai Image image\".to_string()),\n resolution: Some(\n magic_hour::models::V1AiImageGeneratorCreateBodyResolutionEnum::Auto,\n ),\n style: magic_hour::models::V1AiImageGeneratorCreateBodyStyle {\n prompt: \"Cool image\".to_string(),\n tool: Some(\n magic_hour::models::V1AiImageGeneratorCreateBodyStyleToolEnum::AiAnimeGenerator,\n ),\n ..Default::default()\n },\n ..Default::default()\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-image-generator \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Ai Image image\",\n \"image_count\": 1,\n \"model\": \"default\",\n \"aspect_ratio\": \"1:1\",\n \"resolution\": \"auto\",\n \"style\": {\n \"prompt\": \"Cool image\",\n \"tool\": \"ai-anime-generator\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-image-generator\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Ai Image image',\n 'image_count' => 1,\n 'model' => 'default',\n 'aspect_ratio' => '1:1',\n 'resolution' => 'auto',\n 'style' => [\n 'prompt' => 'Cool image',\n 'tool' => 'ai-anime-generator'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-image-generator\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Ai Image image\\\",\\\"image_count\\\":1,\\\"model\\\":\\\"default\\\",\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"resolution\\\":\\\"auto\\\",\\\"style\\\":{\\\"prompt\\\":\\\"Cool image\\\",\\\"tool\\\":\\\"ai-anime-generator\\\"}}\")\n .asString();" /v1/ai-image-upscaler: post: description: Upscale your image using AI. Each 2x upscale costs 50 credits for balanced/creative modes, and 25 credits for preserve. 4x upscale costs 200 and 100 credits respectively. summary: AI Image Upscaler tags: - Image Projects parameters: [] operationId: aiImageUpscaler.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Image Upscaler image default: Image Upscaler - dateTime scale_factor: type: number example: 2 description: "How much to scale the image. Must be either 2 or 4.\n \nNote: 4x upscale is only available on Creator, Pro, or Business tier." style: default: {} type: object properties: mode: type: string enum: - pro - preserve - balanced - creative description: The upscaling mode. `"preserve"` uses the fast pro pipeline (1× credit multiplier). `"balanced"` and `"creative"` use the creative pipeline (2× credit multiplier). `"pro"` is deprecated and maps to `"preserve"`. Defaults to `"balanced"`. example: balanced prompt: type: string description: A prompt to guide the final image. Only used when mode is `creative`. description: Style settings for the upscale. Use `mode` (`"preserve"`, `"balanced"`, or `"creative"`). Defaults to `"balanced"`. assets: type: object properties: image_file_path: type: string minLength: 1 description: 'The image to upscale. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. . The maximum input image size is 4096x4096px.' example: api-assets/id/1234.png required: - image_file_path description: Provide the assets for upscaling required: - scale_factor - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 50 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_image_upscaler.generate(\n assets={\"image_file_path\": \"/path/to/1234.png\"},\n scale_factor=2.0,\n style={\"mode\": \"balanced\"},\n name=\"Image Upscaler image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiImageUpscaler.generate(\n {\n assets: { imageFilePath: \"/path/to/1234.png\" },\n name: \"Image Upscaler image\",\n scaleFactor: 2.0,\n style: { mode: \"balanced\" },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_image_upscaler \"github.com/magichourhq/magic-hour-go/resources/v1/ai_image_upscaler\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiImageUpscaler.Create(ai_image_upscaler.CreateRequest{\n\t\tAssets: types.V1AiImageUpscalerCreateBodyAssets{\n\t\t\tImageFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Image Upscaler image\"),\n\t\tScaleFactor: 2.0,\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_image_upscaler()\n .create(magic_hour::resources::v1::ai_image_upscaler::CreateRequest {\n assets: magic_hour::models::V1AiImageUpscalerCreateBodyAssets {\n image_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Image Upscaler image\".to_string()),\n scale_factor: 2.0,\n ..Default::default()\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-image-upscaler \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Image Upscaler image\",\n \"scale_factor\": 2,\n \"style\": {},\n \"assets\": {\n \"image_file_path\": \"api-assets/id/1234.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-image-upscaler\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Image Upscaler image',\n 'scale_factor' => 2,\n 'style' => [\n \n ],\n 'assets' => [\n 'image_file_path' => 'api-assets/id/1234.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-image-upscaler\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Image Upscaler image\\\",\\\"scale_factor\\\":2,\\\"style\\\":{},\\\"assets\\\":{\\\"image_file_path\\\":\\\"api-assets/id/1234.png\\\"}}\")\n .asString();" /v1/ai-meme-generator: post: description: Create an AI generated meme. Each meme costs 10 credits. summary: AI Meme Generator tags: - Image Projects parameters: [] operationId: aiMemeGenerator.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: The name of the meme. example: My Funny Meme style: type: object properties: topic: type: string maxLength: 200 minLength: 1 description: The topic of the meme. example: When the code finally works template: type: string enum: - Random - Drake Hotline Bling - Galaxy Brain - Two Buttons - Gru's Plan - Tuxedo Winnie The Pooh - Is This a Pigeon - Panik Kalm Panik - Disappointed Guy - Waiting Skeleton - Bike Fall - Change My Mind - Side Eyeing Chloe description: To use our templates, pass in one of the enum values. example: Drake Hotline Bling searchWeb: default: false type: boolean description: Whether to search the web for meme content. example: false required: - topic - template required: - style responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 10 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create meme required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_meme_generator.generate(\n style={\n \"search_web\": False,\n \"template\": \"Drake Hotline Bling\",\n \"topic\": \"When the code finally works\",\n },\n name=\"My Funny Meme\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiMemeGenerator.generate(\n {\n name: \"My Funny Meme\",\n style: {\n searchWeb: false,\n template: \"Drake Hotline Bling\",\n topic: \"When the code finally works\",\n },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_meme_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_meme_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiMemeGenerator.Create(ai_meme_generator.CreateRequest{\n\t\tName: nullable.NewValue(\"My Funny Meme\"),\n\t\tStyle: types.V1AiMemeGeneratorCreateBodyStyle{\n\t\t\tSearchWeb: nullable.NewValue(false),\n\t\t\tTemplate: types.V1AiMemeGeneratorCreateBodyStyleTemplateEnumDrakeHotlineBling,\n\t\t\tTopic: \"When the code finally works\",\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_meme_generator()\n .create(magic_hour::resources::v1::ai_meme_generator::CreateRequest {\n name: Some(\"My Funny Meme\".to_string()),\n style: magic_hour::models::V1AiMemeGeneratorCreateBodyStyle {\n search_web: Some(false),\n template: magic_hour::models::V1AiMemeGeneratorCreateBodyStyleTemplateEnum::DrakeHotlineBling,\n topic: \"When the code finally works\".to_string(),\n },\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-meme-generator \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Funny Meme\",\n \"style\": {\n \"topic\": \"When the code finally works\",\n \"template\": \"Drake Hotline Bling\",\n \"searchWeb\": false\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-meme-generator\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Funny Meme',\n 'style' => [\n 'topic' => 'When the code finally works',\n 'template' => 'Drake Hotline Bling',\n 'searchWeb' => false\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-meme-generator\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Funny Meme\\\",\\\"style\\\":{\\\"topic\\\":\\\"When the code finally works\\\",\\\"template\\\":\\\"Drake Hotline Bling\\\",\\\"searchWeb\\\":false}}\")\n .asString();" /v1/ai-qr-code-generator: post: description: Create an AI QR code. Each QR code costs 0 credits. summary: AI QR Code Generator tags: - Image Projects parameters: [] operationId: aiQrCodeGenerator.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Qr Code image default: Qr Code - dateTime content: type: string description: The content of the QR code. example: https://magichour.ai style: type: object properties: art_style: type: string description: To use our templates, pass in one of Watercolor, Cyberpunk City, Ink Landscape, Interior Painting, Japanese Street, Mech, Minecraft, Picasso Painting, Game Map, Spaceship, Chinese Painting, Winter Village, or pass any custom art style. example: Watercolor required: - art_style required: - content - style responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 0 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.ai_qr_code_generator.generate(\n content=\"https://magichour.ai\",\n style={\"art_style\": \"Watercolor\"},\n name=\"Qr Code image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.aiQrCodeGenerator.generate(\n {\n content: \"https://magichour.ai\",\n name: \"Qr Code image\",\n style: { artStyle: \"Watercolor\" },\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tai_qr_code_generator \"github.com/magichourhq/magic-hour-go/resources/v1/ai_qr_code_generator\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.AiQrCodeGenerator.Create(ai_qr_code_generator.CreateRequest{\n\t\tContent: \"https://magichour.ai\",\n\t\tName: nullable.NewValue(\"My Qr Code image\"),\n\t\tStyle: types.V1AiQrCodeGeneratorCreateBodyStyle{\n\t\t\tArtStyle: \"Watercolor\",\n\t\t},\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .ai_qr_code_generator()\n .create(magic_hour::resources::v1::ai_qr_code_generator::CreateRequest {\n content: \"https://magichour.ai\".to_string(),\n name: Some(\"My Qr Code image\".to_string()),\n style: magic_hour::models::V1AiQrCodeGeneratorCreateBodyStyle {\n art_style: \"Watercolor\".to_string(),\n },\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/ai-qr-code-generator \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Qr Code image\",\n \"content\": \"https://magichour.ai\",\n \"style\": {\n \"art_style\": \"Watercolor\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/ai-qr-code-generator\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Qr Code image',\n 'content' => 'https://magichour.ai',\n 'style' => [\n 'art_style' => 'Watercolor'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/ai-qr-code-generator\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Qr Code image\\\",\\\"content\\\":\\\"https://magichour.ai\\\",\\\"style\\\":{\\\"art_style\\\":\\\"Watercolor\\\"}}\")\n .asString();" /v1/body-swap: post: description: Swap a person into a scene image using Nano Banana 2 Lite (640px/1k) or Nano Banana 2 (2k/4k). Credits depend on `resolution` (from 50 credits at 640px upward). summary: Body Swap tags: - Image Projects parameters: [] operationId: bodySwap.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Body Swap image default: Body Swap - dateTime resolution: type: string enum: - 640px - 1k - 2k - 4k description: Output resolution. Determines credits charged for the run. example: 1k assets: type: object properties: person_file_path: type: string minLength: 1 description: 'Image of the person to place into the scene. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png scene_file_path: type: string minLength: 1 description: 'Original scene image (background). This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/5678.png required: - person_file_path - scene_file_path description: Person image and scene image for body swap required: - resolution - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 50 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.body_swap.generate(\n assets={\n \"person_file_path\": \"/path/to/person.png\",\n \"scene_file_path\": \"/path/to/scene.png\",\n },\n resolution=\"1k\",\n name=\"My Body Swap image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\",\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.bodySwap.generate(\n {\n assets: {\n personFilePath: \"/path/to/person.png\",\n sceneFilePath: \"/path/to/scene.png\",\n },\n name: \"My Body Swap image\",\n resolution: \"1k\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tbody_swap \"github.com/magichourhq/magic-hour-go/resources/v1/body_swap\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.BodySwap.Create(body_swap.CreateRequest{\n\t\tAssets: types.V1BodySwapCreateBodyAssets{\n\t\t\tPersonFilePath: \"api-assets/id/1234.png\",\n\t\t\tSceneFilePath: \"api-assets/id/5678.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Body Swap image\"),\n\t\tResolution: types.V1BodySwapCreateBodyResolutionEnum1k,\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .body_swap()\n .create(magic_hour::resources::v1::body_swap::CreateRequest {\n assets: magic_hour::models::V1BodySwapCreateBodyAssets {\n person_file_path: \"api-assets/id/1234.png\".to_string(),\n scene_file_path: \"api-assets/id/5678.png\".to_string(),\n },\n name: Some(\"My Body Swap image\".to_string()),\n resolution: magic_hour::models::V1BodySwapCreateBodyResolutionEnum::Enum1k,\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/body-swap \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Body Swap image\",\n \"resolution\": \"1k\",\n \"assets\": {\n \"person_file_path\": \"api-assets/id/1234.png\",\n \"scene_file_path\": \"api-assets/id/5678.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/body-swap\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Body Swap image',\n 'resolution' => '1k',\n 'assets' => [\n 'person_file_path' => 'api-assets/id/1234.png',\n 'scene_file_path' => 'api-assets/id/5678.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/body-swap\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Body Swap image\\\",\\\"resolution\\\":\\\"1k\\\",\\\"assets\\\":{\\\"person_file_path\\\":\\\"api-assets/id/1234.png\\\",\\\"scene_file_path\\\":\\\"api-assets/id/5678.png\\\"}}\")\n .asString();" /v1/face-swap-photo: post: description: Create a face swap photo. Each photo costs 10 credits. The height/width of the output image depends on your subscription. Please refer to our [pricing](https://magichour.ai/pricing) page for more details summary: Face Swap Photo tags: - Image Projects parameters: [] operationId: faceSwapPhoto.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Face Swap image default: Face Swap - dateTime assets: type: object properties: face_swap_mode: default: all-faces type: string enum: - all-faces - individual-faces description: 'Choose how to swap faces: **all-faces** (recommended) — swap all detected faces using one source image (`source_file_path` required) +- **individual-faces** — specify exact mappings using `face_mappings`' example: all-faces source_file_path: type: string minLength: 1 description: 'This is the image from which the face is extracted. The value is required if `face_swap_mode` is `all-faces`. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png face_mappings: type: array items: type: object properties: original_face: type: string description: 'The face detected from the image in `target_file_path`. The file name is in the format of `-.png`. This value is corresponds to the response in the [face detection API](https://docs.magichour.ai/api-reference/files/get-face-detection-details). * The face_frame is the frame number of the face in the target image. For images, the frame number is always 0. * The face_index is the index of the face in the target image, starting from 0 going left to right.' example: api-assets/id/0-0.png new_face: type: string description: 'The face image that will be used to replace the face in the `original_face`. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - original_face - new_face maxItems: 5 description: This is the array of face mappings used for multiple face swap. The value is required if `face_swap_mode` is `individual-faces`. example: - original_face: api-assets/id/0-0.png new_face: api-assets/id/1234.png target_file_path: type: string minLength: 1 description: 'This is the image where the face from the source image will be placed. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - target_file_path description: Provide the assets for face swap photo required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 10 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.face_swap_photo.generate(\n assets={\n \"face_mappings\": [\n {\n \"new_face\": \"/path/to/1234.png\",\n \"original_face\": \"api-assets/id/0-0.png\",\n }\n ],\n \"face_swap_mode\": \"all-faces\",\n \"source_file_path\": \"/path/to/1234.png\",\n \"target_file_path\": \"/path/to/1234.png\",\n },\n name=\"Face Swap image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.faceSwapPhoto.generate(\n {\n assets: {\n faceMappings: [\n {\n newFace: \"api-assets/id/1234.png\",\n originalFace: \"api-assets/id/0-0.png\",\n },\n ],\n faceSwapMode: \"all-faces\",\n sourceFilePath: \"/path/to/1234.png\",\n targetFilePath: \"/path/to/1234.png\",\n },\n name: \"Face Swap image\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tface_swap_photo \"github.com/magichourhq/magic-hour-go/resources/v1/face_swap_photo\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.FaceSwapPhoto.Create(face_swap_photo.CreateRequest{\n\t\tAssets: types.V1FaceSwapPhotoCreateBodyAssets{\n\t\t\tFaceMappings: nullable.NewValue([]types.V1FaceSwapPhotoCreateBodyAssetsFaceMappingsItem{\n\t\t\t\ttypes.V1FaceSwapPhotoCreateBodyAssetsFaceMappingsItem{\n\t\t\t\t\tNewFace: \"api-assets/id/1234.png\",\n\t\t\t\t\tOriginalFace: \"api-assets/id/0-0.png\",\n\t\t\t\t},\n\t\t\t}),\n\t\t\tFaceSwapMode: nullable.NewValue(types.V1FaceSwapPhotoCreateBodyAssetsFaceSwapModeEnumAllFaces),\n\t\t\tSourceFilePath: nullable.NewValue(\"api-assets/id/1234.png\"),\n\t\t\tTargetFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Face Swap image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .face_swap_photo()\n .create(magic_hour::resources::v1::face_swap_photo::CreateRequest {\n assets: magic_hour::models::V1FaceSwapPhotoCreateBodyAssets {\n face_mappings: Some(\n vec![\n magic_hour::models::V1FaceSwapPhotoCreateBodyAssetsFaceMappingsItem\n { new_face : \"api-assets/id/1234.png\".to_string(), original_face\n : \"api-assets/id/0-0.png\".to_string() }\n ],\n ),\n face_swap_mode: Some(\n magic_hour::models::V1FaceSwapPhotoCreateBodyAssetsFaceSwapModeEnum::AllFaces,\n ),\n source_file_path: Some(\"api-assets/id/1234.png\".to_string()),\n target_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Face Swap image\".to_string()),\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/face-swap-photo \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Face Swap image\",\n \"assets\": {\n \"face_swap_mode\": \"all-faces\",\n \"source_file_path\": \"api-assets/id/1234.png\",\n \"face_mappings\": [\n {\n \"original_face\": \"api-assets/id/0-0.png\",\n \"new_face\": \"api-assets/id/1234.png\"\n }\n ],\n \"target_file_path\": \"api-assets/id/1234.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/face-swap-photo\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Face Swap image',\n 'assets' => [\n 'face_swap_mode' => 'all-faces',\n 'source_file_path' => 'api-assets/id/1234.png',\n 'face_mappings' => [\n [\n 'original_face' => 'api-assets/id/0-0.png',\n 'new_face' => 'api-assets/id/1234.png'\n ]\n ],\n 'target_file_path' => 'api-assets/id/1234.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/face-swap-photo\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Face Swap image\\\",\\\"assets\\\":{\\\"face_swap_mode\\\":\\\"all-faces\\\",\\\"source_file_path\\\":\\\"api-assets/id/1234.png\\\",\\\"face_mappings\\\":[{\\\"original_face\\\":\\\"api-assets/id/0-0.png\\\",\\\"new_face\\\":\\\"api-assets/id/1234.png\\\"}],\\\"target_file_path\\\":\\\"api-assets/id/1234.png\\\"}}\")\n .asString();" /v1/head-swap: post: description: Swap a head onto a body image. Each image costs 10 credits. Output resolution depends on your subscription; you may set `max_resolution` lower than your plan maximum if desired. summary: Head Swap tags: - Image Projects parameters: [] operationId: headSwap.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Head Swap image default: Head Swap - dateTime max_resolution: type: integer description: Constrains the larger dimension (height or width) of the output. Omit to use the maximum allowed for your plan (capped at 2048px). Values above your plan maximum are clamped down to your plan's maximum. example: 1024 assets: type: object properties: body_file_path: type: string minLength: 1 description: 'Image that receives the swapped head. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png head_file_path: type: string minLength: 1 description: 'Image of the head to place on the body. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/5678.png required: - body_file_path - head_file_path description: Provide the body and head images for head swap required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 10 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.head_swap.generate(\n assets={\n \"body_file_path\": \"/path/to/body.png\",\n \"head_file_path\": \"/path/to/head.png\",\n },\n max_resolution=1024,\n name=\"My Head Swap image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\",\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.headSwap.create({\n assets: {\n bodyFilePath: \"api-assets/id/1234.png\",\n headFilePath: \"api-assets/id/5678.png\",\n },\n maxResolution: 1024,\n name: \"My Head Swap image\",\n});" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\thead_swap \"github.com/magichourhq/magic-hour-go/resources/v1/head_swap\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.HeadSwap.Create(head_swap.CreateRequest{\n\t\tAssets: types.V1HeadSwapCreateBodyAssets{\n\t\t\tBodyFilePath: \"api-assets/id/1234.png\",\n\t\t\tHeadFilePath: \"api-assets/id/5678.png\",\n\t\t},\n\t\tMaxResolution: nullable.NewValue(1024),\n\t\tName: nullable.NewValue(\"My Head Swap image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .head_swap()\n .create(magic_hour::resources::v1::head_swap::CreateRequest {\n assets: magic_hour::models::V1HeadSwapCreateBodyAssets {\n body_file_path: \"api-assets/id/1234.png\".to_string(),\n head_file_path: \"api-assets/id/5678.png\".to_string(),\n },\n max_resolution: Some(1024),\n name: Some(\"My Head Swap image\".to_string()),\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/head-swap \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Head Swap image\",\n \"max_resolution\": 1024,\n \"assets\": {\n \"body_file_path\": \"api-assets/id/1234.png\",\n \"head_file_path\": \"api-assets/id/5678.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/head-swap\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Head Swap image',\n 'max_resolution' => 1024,\n 'assets' => [\n 'body_file_path' => 'api-assets/id/1234.png',\n 'head_file_path' => 'api-assets/id/5678.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/head-swap\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Head Swap image\\\",\\\"max_resolution\\\":1024,\\\"assets\\\":{\\\"body_file_path\\\":\\\"api-assets/id/1234.png\\\",\\\"head_file_path\\\":\\\"api-assets/id/5678.png\\\"}}\")\n .asString();" /v1/image-background-remover: post: description: Remove background from image. Each image costs 5 credits. summary: Image Background Remover tags: - Image Projects parameters: [] operationId: imageBackgroundRemover.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Background Remover image default: Background Remover - dateTime assets: type: object properties: image_file_path: type: string description: 'The image to remove the background. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png background_image_file_path: type: string description: 'The image used as the new background for the image_file_path. This image will be resized to match the image in image_file_path. Please make sure the resolution between the images are similar. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - image_file_path description: Provide the assets for background removal required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 5 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.image_background_remover.generate(\n assets={\n \"background_image_file_path\": \"/path/to/1234.png\",\n \"image_file_path\": \"/path/to/1234.png\",\n },\n name=\"Background Remover image\",\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.imageBackgroundRemover.generate(\n {\n assets: {\n backgroundImageFilePath: \"/path/to/1234.png\",\n imageFilePath: \"/path/to/1234.png\",\n },\n name: \"Background Remover image\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\timage_background_remover \"github.com/magichourhq/magic-hour-go/resources/v1/image_background_remover\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.ImageBackgroundRemover.Create(image_background_remover.CreateRequest{\n\t\tAssets: types.V1ImageBackgroundRemoverCreateBodyAssets{\n\t\t\tBackgroundImageFilePath: nullable.NewValue(\"api-assets/id/1234.png\"),\n\t\t\tImageFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Background Remover image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .image_background_remover()\n .create(magic_hour::resources::v1::image_background_remover::CreateRequest {\n assets: magic_hour::models::V1ImageBackgroundRemoverCreateBodyAssets {\n background_image_file_path: Some(\"api-assets/id/1234.png\".to_string()),\n image_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Background Remover image\".to_string()),\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/image-background-remover \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Background Remover image\",\n \"assets\": {\n \"image_file_path\": \"api-assets/id/1234.png\",\n \"background_image_file_path\": \"api-assets/id/1234.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/image-background-remover\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Background Remover image',\n 'assets' => [\n 'image_file_path' => 'api-assets/id/1234.png',\n 'background_image_file_path' => 'api-assets/id/1234.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/image-background-remover\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Background Remover image\\\",\\\"assets\\\":{\\\"image_file_path\\\":\\\"api-assets/id/1234.png\\\",\\\"background_image_file_path\\\":\\\"api-assets/id/1234.png\\\"}}\")\n .asString();" /v1/photo-colorizer: post: description: Colorize image. Each image costs 10 credits. summary: Photo Colorizer tags: - Image Projects parameters: [] operationId: photoColorizer.createImage requestBody: required: true description: Body content: application/json: schema: type: object properties: name: type: string description: Give your image a custom name for easy identification. example: My Photo Colorizer image default: Photo Colorizer - dateTime assets: type: object properties: image_file_path: type: string minLength: 1 description: 'The image used to generate the colorized image. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. ' example: api-assets/id/1234.png required: - image_file_path description: Provide the assets for photo colorization required: - assets responses: '200': description: Success content: application/json: schema: type: object properties: id: type: string example: cuid-example description: Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads. credits_charged: type: integer description: "The amount of credits deducted from your account to generate the image. We charge credits right when the request is made. \n\nIf an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund." example: 10 required: - id - credits_charged description: Success '400': description: Invalid Request content: application/json: schema: type: object properties: message: type: string required: - message description: The request is invalid example: message: Missing request body '401': description: Unauthorized content: application/json: schema: type: object properties: message: type: string enum: - Unauthorized required: - message description: The request is not properly authenticated example: message: Unauthorized '402': description: Payment Required content: application/json: schema: type: object properties: message: type: string required: - message description: The request requires payment example: message: Payment required '404': description: Not Found content: application/json: schema: type: object properties: message: type: string enum: - Not Found required: - message description: Requested resource is not found example: message: Not Found '422': description: Unprocessable Entity content: application/json: schema: type: object properties: message: type: string example: Unable to create image required: - message description: Unprocessable Entity security: - bearerAuth: [] x-codeSamples: - lang: python source: "from magic_hour import Client\nfrom os import getenv\n\nclient = Client(token=getenv(\"API_TOKEN\"))\nres = client.v1.photo_colorizer.generate(\n assets={\"image_file_path\": \"/path/to/1234.png\"}, name=\"Photo Colorizer image\"\n wait_for_completion=True,\n download_outputs=True,\n download_directory=\".\"\n)" - lang: javascript source: "import { Client } from \"magic-hour\";\n\nconst client = new Client({ token: process.env[\"API_TOKEN\"]!! });\nconst res = await client.v1.photoColorizer.generate(\n {\n assets: { imageFilePath: \"/path/to/1234.png\" },\n name: \"Photo Colorizer image\",\n },\n {\n waitForCompletion: true,\n downloadOutputs: true,\n downloadDirectory: \".\",\n },\n);" - lang: go source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\tphoto_colorizer \"github.com/magichourhq/magic-hour-go/resources/v1/photo_colorizer\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.PhotoColorizer.Create(photo_colorizer.CreateRequest{\n\t\tAssets: types.V1PhotoColorizerCreateBodyAssets{\n\t\t\tImageFilePath: \"api-assets/id/1234.png\",\n\t\t},\n\t\tName: nullable.NewValue(\"My Photo Colorizer image\"),\n\t})\n}" - lang: rust source: "let client = magic_hour::Client::default()\n .with_bearer_auth(&std::env::var(\"API_TOKEN\").unwrap());\nlet res = client\n .v1()\n .photo_colorizer()\n .create(magic_hour::resources::v1::photo_colorizer::CreateRequest {\n assets: magic_hour::models::V1PhotoColorizerCreateBodyAssets {\n image_file_path: \"api-assets/id/1234.png\".to_string(),\n },\n name: Some(\"My Photo Colorizer image\".to_string()),\n })\n .await;" - lang: curl source: "curl --request POST \\\n --url https://api.magichour.ai/v1/photo-colorizer \\\n --header 'accept: application/json' \\\n --header 'authorization: Bearer ' \\\n --header 'content-type: application/json' \\\n --data '\n{\n \"name\": \"My Photo Colorizer image\",\n \"assets\": {\n \"image_file_path\": \"api-assets/id/1234.png\"\n }\n}\n'" - lang: php source: " \"https://api.magichour.ai/v1/photo-colorizer\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => json_encode([\n 'name' => 'My Photo Colorizer image',\n 'assets' => [\n 'image_file_path' => 'api-assets/id/1234.png'\n ]\n ]),\n CURLOPT_HTTPHEADER => [\n \"accept: application/json\",\n \"authorization: Bearer \",\n \"content-type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}" - lang: java source: "HttpResponse response = Unirest.post(\"https://api.magichour.ai/v1/photo-colorizer\")\n .header(\"accept\", \"application/json\")\n .header(\"content-type\", \"application/json\")\n .header(\"authorization\", \"Bearer \")\n .body(\"{\\\"name\\\":\\\"My Photo Colorizer image\\\",\\\"assets\\\":{\\\"image_file_path\\\":\\\"api-assets/id/1234.png\\\"}}\")\n .asString();" components: securitySchemes: bearerAuth: type: http scheme: bearer description: Bearer authentication header of the form `Bearer `, where `` is your API key. To get your API key, go to [Developer Hub](https://magichour.ai/developer?tab=api-keys&utm_source=docs&utm_medium=referral&utm_campaign=api-reference) and click "Create new API Key".