# Apiframe v2 \[Important]

⚠️ If you created your account after the 28th of April, you are likely on Apiframe v2.\
Here are the docs for v2: <https://apiframe.ai/docs> <br>

Apiframe v2 is not compatible with v1; you can't use the API Keys interchangeably. Apiframe v2 API keys start with `afk_`&#x20;


# What's the Pro API?

Just another Midjourney API, but different.

Here is the cost of each action:

* **Imagine**: 6 credits in fast mode and 10 in turbo mode
* **Vary Strong and Creative**: 6 credits
* **Upscale Subtle, and Creative**: 10 credits
* **Variations:** 6 credits

If you use Zapier, Make, N8N, or Pabbly Connect, you can use the direct API instead of an integration. If you need help, contact us on our [Discord](https://discord.gg/pM3qyNAXXC).


# API Endpoints

New Midjourney API endpoints

{% content-ref url="/pages/aG31Vc8GrQgAggw1dPXe" %}
[Imagine](/pro-midjourney-api/api-endpoints/imagine)
{% endcontent-ref %}

{% content-ref url="/pages/hgUyN9l2rK4USh2tp9Mp" %}
[Vary Strong and Subtle](/pro-midjourney-api/api-endpoints/vary-strong-and-subtle)
{% endcontent-ref %}

{% content-ref url="/pages/RrA7QA6AlzoSNlbkBF2I" %}
[Upscale Subtle and Creative](/pro-midjourney-api/api-endpoints/upscale-subtle-and-creative)
{% endcontent-ref %}

{% content-ref url="/pages/Ev2lByL8pFOBrpCJxbcs" %}
[Variations](/pro-midjourney-api/api-endpoints/variations)
{% endcontent-ref %}

{% content-ref url="/pages/TB1XRy6monRp0lrN1aGB" %}
[Pan](/pro-midjourney-api/api-endpoints/pan)
{% endcontent-ref %}

{% content-ref url="/pages/tEu1esxDB7TMdjD6ptAU" %}
[Zoom](/pro-midjourney-api/api-endpoints/zoom)
{% endcontent-ref %}


# Imagine

Generate four images from a text prompt. Available versions are 6.1 and 7

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/imagine`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The text prompt for Midjourney AI</td></tr><tr><td><code>mode</code></td><td>string</td><td>Can be <strong>fast</strong> or <strong>turbo</strong></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Vary Strong and Subtle

Generate four (4) new images from a previous generation task: Imagine, Upscale, Vary, or Variations.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/vary`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>strong</strong> or <strong>subtle</strong></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Upscale Subtle and Creative

Upscale an image (2X) while keeping the details (Subtle) or adding some details (Creative). Can be done after: Imagine, Vary, or Variations.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/upscale`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>subtle</strong> or <strong>creative</strong></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Variations

Generate four (4) new images from a previous generation task: Imagine, Upscale, Vary, or Variations.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/variations`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Pan

Pan an existing image (from Midjourney) to one direction: Up, Down, Right or Left

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/pan`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The pan direction, can be <strong>up</strong>, <strong>down</strong>, <strong>right</strong>, or <strong>left</strong></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Zoom

Zoom an existing image (from Midjourney); the zoom ratio from 1 to 2

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/zoom`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td><p>The zoom ratio.<br>Can be:</p><ul><li>1.5 for MJ button "zoom out 1.5x"</li><li>2 for MJ button "zoom out 2x"</li><li>(1, 2] for MJ button "custom zoom"</li><li>1 for MJ button "make square"</li></ul><p>You can take a look <a href="https://docs.midjourney.com/docs/zoom-out">here</a></p></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Inpaint

Partially redraw an area of an image.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/inpaint`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index </code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Can be <strong>1, 2, 3,</strong> or <strong>4</strong></td></tr><tr><td><code>mask</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Base64 encoding of the image corresponding to the selected area</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Drawing prompt for selected areas</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Seed

Get the seed of a previous task

<mark style="color:green;">`POST`</mark> `https://api.apiframe.ai/pro/seed`

**Headers**

| Name                                            | Value                   |
| ----------------------------------------------- | ----------------------- |
| Content-Type                                    | `application/json`      |
| Authorization<mark style="color:red;">\*</mark> | `Your APIFRAME API Key` |

**Body**

<table><thead><tr><th width="196.8828125">Name</th><th width="133.4296875">Type</th><th width="417.84375">Description</th></tr></thead><tbody><tr><td><code>task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>Task updates will be posted at this URL</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Unauthorized
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the seed instantly; You can use the [Fetch](https://docs.apiframe.ai/api-endpoints/fetch) endpoint to fetch the result or [webhooks](https://docs.apiframe.ai/webhooks).


# Can I still use the Original API?

Of course, you can still use the Original API; just remember that it's slower than the new Pro API. If you have a project that requires fast generations, we recommend switching to the Pro API.

Also, the Pro API is only a Midjourney API, so if you need other APIs, you should stick with the Old API or use both.


# Get Started

Explore comprehensive documentation for the Midjourney API, designed to simplify and optimize your development workflow.

<figure><img src="https://apiframe.pro/images/meta-image.png" alt="Midjourney API Documentation"><figcaption><p>APIFRAME: Midjourney API</p></figcaption></figure>

### Introduction to Midjourney API Documentation

#### Understanding the Midjourney API

The [Midjourney API ](https://apiframe.pro)is a powerful tool that enables developers to generate high-quality images, illustrations, and visual content programmatically. It offers a range of features designed to simplify and enhance the creation of stunning visuals:

* **Image Generation**: The API allows you to generate images and create custom images based on text prompts. Whether you need product mockups, social media graphics, or personalized illustrations, we have you covered.
* **Scalability**: As your user base grows, the API scales effortlessly to handle high demand. It adapts seamlessly to varying workloads, ensuring near-zero downtime for your applications.
* **Integration**: APIFRAME provides clear documentation and endpoints, making it easy to integrate into your existing applications regardless of the programming language you use, such as Python or JavaScript.

APIFRAME offers an extensive list of API endpoints to interact with the Midjourney AI. The most commonly used endpoint is the [Imagine](https://docs.apiframe.pro/api-endpoints/imagine) endpoint, which allows you to create AI images programmatically using a text prompt. Some key use cases for the Midjourney API include:

* Enhancing product listings with realistic mockups for e-commerce sites
* Creating eye-catching graphics for social media marketing campaigns
* Generating unique, custom illustrations to spice up website designs

#### Benefits of Using APIFRAME for Midjourney API Integration

The benefits of using APIFRAME are significant. It eliminates the need for manual image creation, saving valuable time and effort. The API ensures consistency by producing uniform images based on your specifications. And as mentioned, it scales effortlessly as your needs grow. To get started, simply create an account on [APIFRAME](https://apiframe.pro/connect), obtain your API key, and follow the comprehensive documentation to integrate the Midjourney API into your applications. With APIFRAME, you can start leveraging the power of AI image generation to create stunning visuals that captivate your audience.\
Here is a guide on [how to create and account and get a Midjourney api key](https://blog.apiframe.pro/how-to-get-a-midjourney-api-key-a-detailed-guide)!

#### Key Features of Midjourney API Documentation

The Midjourney API documentation provided by APIFRAME offers several key features that make it an invaluable resource for developers:

* **Comprehensive Endpoints**: The documentation covers an extensive list of API endpoints, allowing developers to fully leverage the capabilities of the Midjourney AI. From the commonly used Imagine endpoint for generating images from text prompts to more advanced features, the documentation provides detailed information on how to use the API endpoints to generate images from text prompts.
* **Clear Examples**: The documentation includes clear examples of how to use the API endpoints in various programming languages, such as JavaScript and Python. These examples make it easy for developers to understand how to integrate the API into their applications.

### Exploring a few Midjourney API Endpoints

The API offers a range of powerful endpoints that enable developers to generate and manipulate AI images programmatically. Let's explore a few key endpoints:

* [**/imagine**](/api-endpoints/imagine): This is the most commonly used endpoint, allowing you to generate images and create custom images based on text prompts. Simply provide a descriptive prompt, and the AI will generate a stunning visual that matches your specifications. You can also customize the image aspect ratio and other parameters to fine-tune the output. This will produce a set of 4 images.
* [**/variations**](/api-endpoints/variations): If you like one of the four images generated by the /imagine request and you'd like to generate more images like it,  the /variations endpoint is your go-to solution. By providing the job ID of the original image and specifying the desired change via a text prompt, you can easily create variations of the original images. This also produces 4 images.
* [**/blend**](/api-endpoints/blend): The /blend endpoint enables you to seamlessly combine multiple images into a single, cohesive visual. This is particularly useful when you want to experience some fun combination of different images. Simply provide the URLs of the images you wish to blend, and the API will work its magic. Like the two previous endpoint, the /blend endpoint will produce 4 images.
* [**/describe**](/api-endpoints/describe): Sometimes, you may have an image that you'd like to understand better or just want to "describe" it. The /describe endpoint uses advanced computer vision techniques to analyze an image and provide a detailed description of its contents. This can be incredibly helpful for categorization, searching, or accessibility purposes.
* [**/faceswap**](/api-endpoints/faceswap): For more creative applications, the /faceswap endpoint allows you to swap faces between two images. Provide the source and target image URLs, each containing a single face, and the API will seamlessly transfer the facial features from one image to the other. This opens up a world of possibilities for fun and engaging visuals.

These are just a few examples of the endpoints available through APIFRAME. By leveraging these powerful tools, developers can create, manipulate, and enhance images programmatically, streamlining their creative processes and delivering stunning visuals to their users.

### Authentication and Security

Authentication and security are crucial aspects of APIFRAME to ensure that only authorized users can access the API endpoints and that sensitive data remains protected. The API implements several measures to safeguard user accounts and maintain data integrity:

* [**API Token Authentication**](/api-endpoints/authentication): To authenticate API requests, the API utilizes API Key authentication. Users must include their API token in the request headers to verify their identity and grant access to the API resources. This ensures that only authorized users with valid tokens can interact with the API.
* **Webhook Secret**: To provide real time updates to users about their tasks, the API utilizes webhooks. However, anyone can actually send requests to your webhook endpoints and harm your backend/app. That's why a webhook secret field is present for all task request to make sure the data posted to your webhook endpoints come from APIFRAME and not an "unwanted" source.
* **Secure Communication**: All communication between the client and the API is encrypted using HTTPS/SSL protocols. This protects data transmitted over the network from interception and unauthorized access, maintaining the confidentiality of user information and generated content. It's also recommended to use HTTPS for your webhook endpoints.
* [**Stealth Mode Generation**](https://docs.midjourney.com/docs/stealth): All images generated with the  API are generated in the Stealth mode. You are the only one who has access to the images you create.
* **Input Validation and Sanitization**: To mitigate security risks, the Midjourney API validates and sanitizes user inputs before processing them. It's also a good idea to sanitize the data on your side before sending them to provide better user experience to your users.

By implementing these authentication and security measures, the Midjourney API provides a secure environment for developers to integrate and utilize its powerful image generation capabilities without compromising user data or system integrity.

### Best Practices for Midjourney API Integration

When integrating the Midjourney API into your development process, following best practices ensures a smooth and efficient experience. Here are some key considerations:

* **Using Webhooks instead of Polling**:  To get updates for submitted task, you can use webhooks or be polling the [Fetch](/api-endpoints/fetch) endpoint. Webhooks are preferable to polling as they provide real-time updates and reduce unnecessary API calls, helping to identify issues, optimize integration, and ensure smooth operation.
* **Keep API Credentials Secure**: Store your API Key securely and avoid exposing them in client-side code or version control systems. Use environment variables or secure configuration files to manage sensitive information. Anyone with the API Key can generate, modify images with your account.

By following these best practices, you can effectively integrate the Midjourney API into your development workflow, create reliable and efficient applications, and deliver exceptional experiences to your users.

### Community and Support

You can get support by using the chat widget available on the [website](https://apiframe.pro) or join our [Telegram community](https://t.me/midjourney_apis) recently created. The documentation also includes a frequently asked questions ([FAQ](/faq)) section that addresses common queries and provides solutions to typical issues encountered during API integration. This section helps developers quickly find answers to their questions and resolve any challenges they may face.


# My Account


# Image credits

What are image credits?

Image credits are used for image processing actions like:

* Generating new images (Imagine, Reroll, Blend, Faceswap)
* Updating generated images (Upscale, Variations, Inpaint, Outpaint, Pan)
* and reading images (Describe)

An image credit can be bought when you run out of credits.

Here is the breakdown of how much each action costs:

* **Imagine / Blend / Reroll**: 4 credits.
* **Variations / Outpaint / Inpaint / Pan / Blend**: 4 credits in Fast mode
* **Describe / Shorten / Seed / 1x Upscale (U1, U2, U3 and U4)**: 2 credits
* **Faceswap**: 2 credits for high resolution
* **2x Upscale**: 1 credits
* **4x Upscale**: 2 credits
* **Upscale (subtle) / Upscale (creative)**: 4 credits
* **Luma Imagine and Extend**: 6 credits
* **Suno**: Imagine and Extend 2 credits, Lyrics 1 credit
* **Flux:** 1 credit
* **Ideogram**: 1 credit for old models and 3 credits for the new v3 model
* **Udio**: 1 credit for udio32-v1.5 and 2  credits for udio130-v1.5
* **Runway ML**: 4 credits
* **Kling 2.5 Turbo Pro**:  10 credits for 5 secs, 20 credits for 10 secs
* **Kling 2.6**: 10 credits for 5 secs (20 credits with audio), 20 credits for 10 secs (40 credits with audio)
* **AI Photos -  Upload and Prepare**: 2 credits
* **AI Photos - Train Model**: 4 credits per training image, so 40 credits for 10 training images
* **AI Photos - Generate Photo**: 1 credit per photo

[BUY CREDITS HERE](https://app.apiframe.ai/dashboard/billing/subscription)


# Generation modes

Midjourney AI generation modes

[Midjourney AI](https://www.midjourney.com/home) offers 3 generation modes: Fast Mode, Turbo Mode and Relax Mode.

The difference between these modes is the generation time and cost. A generation in Fast mode typically takes a minute, when it only takes about 15 seconds in Turbo mode. The Relax mode is much slower and depends on the available resources. We ([APIFRAME](https://apiframe.pro/)) only offer Fast mode; if you need Turbo mode, please [let us know](https://chatting.page/4kfl67eg5gmwmuenx91bowbjp4dt0wq8).


# Delete My Account

Do you need to delete your account and all data associated with it?

Send us an email at <hello@apiframe.pro> and we will process your request.


# Apiframe SDKs


# Node.js SDK

The Node.js SDK is available at <https://www.npmjs.com/package/@apiframe-ai/sdk>


# Python SDK

The Python client is available at <https://pypi.org/project/apiframe-sdk/>


# Go SDK

The Go client  <https://github.com/apiframe-ai/apiframe-go-sdk>


# PHP SDK

The PHP SDK is available at <https://github.com/apiframe-ai/apiframe-php-sdk>


# MEDIA UPLOAD APIS

A set of APIs to upload media file to APIFRAME and use them later for other tasks.

{% content-ref url="/pages/6Oo5UFkafTd3TS1PzkNH" %}
[Upload Image](/media-upload-apis/upload-image)
{% endcontent-ref %}

{% content-ref url="/pages/1D1zi9aCjODy0Qjzwreu" %}
[Upload Audio](/media-upload-apis/upload-audio)
{% endcontent-ref %}


# Upload Image

Upload an image and get an image URL. You can then use this image URL in your prompts.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/upload`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `multipart/form-data` |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image</code><mark style="color:red;"><code>*</code></mark></td><td>binary</td><td>The image file you want to upload. Maximum 2MB!</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "imageURL": "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxxxxxxx.png"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('image', fs.createReadStream('..../image.png'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/upload',
  headers: { 
    'Authorization': 'YOUR_API_KEY', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.apiframe.pro/upload"

payload = {}
files=[
  ('image',('Vector.png',open('..../image.png','rb'),'image/png'))
]
headers = {
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/upload',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('..../image.png')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("image","",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("..../image.png")))
  .build();
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/upload")
  .method("POST", body)
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Authorization': 'YOUR_API_KEY'
};
var data = FormData.fromMap({
  'files': [
    await MultipartFile.fromFile('..../image.png', filename: '')
  ],

});

var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/upload',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upload");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("..../image.png")), "image", "zlpGHQ2ic/Vector.png");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.apiframe.pro/upload")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "YOUR_API_KEY"
form_data = [['image', File.open('.../image.png')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Upload Audio

You can upload an audio file and get an audio URL. You can then use this audio URL for other tasks, such as the Suno AI Extend task.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/upload-audio`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `multipart/form-data` |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>audio</code><mark style="color:red;"><code>*</code></mark></td><td>binary</td><td>The audio file you want to upload. Maximum 2MB.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task is complete
{
  "audioURL": "https://cdn.apiframe.pro/songs/xxxxxxxxxxxxxxxxxxx.mp4"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('audio', fs.createReadStream('..../audio.mp4'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/upload-audio',
  headers: { 
    'Authorization': 'YOUR_API_KEY', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.apiframe.pro/upload-audio"

payload = {}
files=[
  ('image',('audio.mp4',open('..../audio.mp4','rb'),'audio/mp4'))
]
headers = {
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/upload-audio',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('audio'=> new CURLFILE('..../audio.mp4')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("audio","",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("..../audio.mp4")))
  .build();
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/upload-audio")
  .method("POST", body)
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Authorization': 'YOUR_API_KEY'
};
var data = FormData.fromMap({
  'files': [
    await MultipartFile.fromFile('..../audio.mp4', filename: '')
  ],

});

var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/upload-audio',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upload-audio");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("..../audio.mp4")), "audio", "zlpGHQ2ic/Audio.mp4");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.apiframe.pro/upload-audio")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "YOUR_API_KEY"
form_data = [['audio', File.open('.../audio.mp4')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Nano Banana

Generate and edit amazing images with Nano Banana

{% content-ref url="/pages/tbmLnaFEivuoxT7NRcR9" %}
[Nano Banana](/nano-banana/nano-banana)
{% endcontent-ref %}

{% content-ref url="/pages/f2L8hojXphYy04szmDAt" %}
[Nano Banana Pro](/nano-banana/nano-banana-pro)
{% endcontent-ref %}


# Nano Banana

Generate or edit images with Google's Nano Banana

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/nano-banana`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The text prompt for generating or editing images</td></tr><tr><td><code>images</code><mark style="color:red;"><code>*</code></mark></td><td>[string]</td><td>Array of image URLs or Base64 of the images to edit</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>aspect_ratio should be one of: match_input_image, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9! By default, it is match_input_image</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "34f439ce-b545-4c57-a5bd-a3xxxxxxxx",
  "image_urls": [
    "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxxxxxxxx.png"
  ],
  "status": "finished",
  "task_type": "nano-banana"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}


# Nano Banana Pro

Generate or edit images with Google's Nano Banana Pro

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/nano-banana-pro`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The text prompt for generating or editing images</td></tr><tr><td><code>images</code></td><td>[string]</td><td>Array of image URLs or Base64 of the images to edit</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>aspect_ratio should be one of: match_input_image, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9! By default, it is match_input_image</td></tr><tr><td><code>resolution</code></td><td>string</td><td>resolution should be one of: 1K, 2K, 4K! By default, it is 2K</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "34f439ce-b545-4c57-a5bd-a3xxxxxxxx",
  "image_urls": [
    "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxxxxxxxx.png"
  ],
  "status": "finished",
  "task_type": "nano-banana-pro"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}


# MIDJOURNEY

Midjourney API endpoints details


# Read this

If you need fast generations (from 14s), please use the [Pro API](/pro-midjourney-api/api-endpoints).


# Authentication

To authenticate your API calls set the Authorization header to your API Key.

You can find your API Key on the [Dashboard](https://app.apiframe.pro/account).

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/[any_endpoint]`

**Headers**

| Name                                            | Value              |
| ----------------------------------------------- | ------------------ |
| Content-Type                                    | `application/json` |
| Authorization<mark style="color:red;">\*</mark> | `YOUR_API_KEY`     |


# Imagine

Generate an image using a text prompt. This is the /imagine command on Discord.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for Midjourney AI</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the image. Default: 1:1</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "sref": "1234578888888", // Only if you used --sref
    "task_type": "imagine",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "imagine",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/imagine"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind",
    "aspect_ratio": "3:2",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"aspect_ratio\": \"3:2\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"aspect_ratio\": \"3:2\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Imagine Video

Generate videos using a text prompt and an image URL.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/imagine-video`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for Midjourney AI</td></tr><tr><td><code>image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The image URL to use as the start frame. Can be generated using the /imagine endpoint.</td></tr><tr><td><code>motion</code></td><td>string</td><td>Can be <strong>low</strong> or <strong>high</strong>. <strong>low</strong> by default.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate videos instantly; you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "imagine-video",
    "video_urls": [
        "https://.../xxxx1.mp4",
        "https://.../xxxx2.mp4",
        "https://.../xxxx3.mp4",
        "https://.../xxxx4.mp4"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "imagine-video",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/imagine-video',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data: data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/imagine-video"

payload = json.dumps({
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/imagine-video',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a cat dancing",
    "image_url": "https://............xxx.png",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a cat dancing\",\r\n    \"image_url\": \"https://............xxx.png\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/imagine-video")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/imagine-video',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/imagine-video");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a cat dancing\",\r\n    \"image_url\": \"https://............xxx.png\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/imagine-video")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Extend Video

Extend previously generated videos.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/imagine-video-extend`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original video task</td></tr><tr><td><code>index</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The index of the image to create variations from. Can be 1, 2, 3 or 4</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for Midjourney AI</td></tr><tr><td><code>image_url</code></td><td>string</td><td>The image URL to use as the start frame. Can be generated using the /imagine endpoint.</td></tr><tr><td><code>motion</code></td><td>string</td><td>Can be <strong>low</strong> or <strong>high</strong>. <strong>low</strong> by default.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate videos instantly; you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "imagine-video-extend",
    "video_urls": [
        "https://.../xxxx1.mp4",
        "https://.../xxxx2.mp4",
        "https://.../xxxx3.mp4",
        "https://.../xxxx4.mp4"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "imagine-video-extend",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a cat dancing",
  "parent_task_id": "29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a",
  "index": "1",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/imagine-video',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data: data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/imagine-video"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a",
  "index": "1",
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/imagine-video',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a",
    "index": "1",
    "prompt": "a cat dancing",
    "image_url": "https://............xxx.png",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"parent_task_id\": \"29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a\",\r\n  \"index\": \"1\",\r\n    \"prompt\": \"a cat dancing\",\r\n    \"image_url\": \"https://............xxx.png\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/imagine-video")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a",
  "index": "1",
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/imagine-video',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/imagine-video");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n \"parent_task_id\": \"29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a\",\r\n  \"index\": \"1\",\r\n    \"prompt\": \"a cat dancing\",\r\n    \"image_url\": \"https://............xxx.png\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/imagine-video")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4887-a9e3-ef6fe9cd5f2a",
  "index": "1",
  "prompt": "a cat dancing",
  "image_url": "https://............xxx.png",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Reroll

Reroll to create new images from a previous Imagine task.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/reroll`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="212">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>prompt</code></td><td>string</td><td>Prompt for re-drawing default value: original prompt from parent task</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "taskId": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "reroll",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "reroll",
    "status": "processing",
    "percentage": "80",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');
const data = JSON.stringify({
<strong>  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
</strong>  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/reroll',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/reroll"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/reroll',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "prompt": "a sunflower field in the wind",
    "aspect_ratio": "3:2",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"aspect_ratio\": \"3:2\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/reroll")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/reroll',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/reroll");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"aspect_ratio\": \"3:2\",\r\n   \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/reroll")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "prompt": "a sunflower field in the wind",
  "aspect_ratio": "3:2",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}

dd


# Upscales

Enhance previously generated images by upscaling them.

{% content-ref url="/pages/AnfEpP2Djal0wxRD8QIN" %}
[Upscale 1x](/api-endpoints/upscales/upscale-1x)
{% endcontent-ref %}

{% content-ref url="/pages/J4EIqz78bLfEfNj4YtTx" %}
[Upscale: Creative and Subtle](/api-endpoints/upscales/upscale-creative-and-subtle)
{% endcontent-ref %}

{% content-ref url="/pages/cy9vmhIJDICFKvi9QoXp" %}
[Upscale: 2x and 4x](/api-endpoints/upscales/upscale-2x-and-4x)
{% endcontent-ref %}


# Upscale 1x

Upscale one of the 4 generated images by the Imagine endpoint to get a single image.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/upscale-1x`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The index of the image to upscale. Can be 1, 2, 3 or 4</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "image_url": "https://............./xxxxx.png",
    "task_type": "upscale#1"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_url": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "upscale#1",
    "status": "processing",
    "percentage": "80",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/upscale-1x',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/upscale-1x"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/upscale-1x',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "index": "2"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"index\": \"2\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/upscale-1x")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/upscale-1x',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upscale-1x");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"index\": \"2\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/upscale-1x")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Upscale: Creative and Subtle

The Upscale (Subtle) option doubles the size of your image and keeps details very similar to the original adds Upscale (Creative) adds details to the image. Of course you first need to Upscale 1x.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/upscale-alt`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the image to upscale, you get it from the <code>/upscale-1x</code> request.</td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The type of upscale. Can be "subtle" or "creative"</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "image_url": "https://............./xxxxx.png",
    "task_type": "upscale-creative"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "upscale-creative",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "creative"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/upscale-alt',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/upscale-alt"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "creative"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/upscale-alt',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "type": "creative"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"type\": \"ceative\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/upscale-alt")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "creative"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/upscale-alt',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upscale-alt");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"type\": \"ceative\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/upscale-alt")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "creative"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Upscale: 2x and 4x

Upscale any image to higher resolution, this is not from Midjourney. Image must not be larger than 2048x2048.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/upscale-highres`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code></td><td>string</td><td>The task ID of the image to upscale. <mark style="color:red;"><code>*</code></mark> Required if you don't provide an <code>image_url</code></td></tr><tr><td><code>image_url</code></td><td>string</td><td>The URL of the image to upscale. <mark style="color:red;"><code>*</code></mark> Required if you don't provide a <code>parent_task_id</code></td></tr><tr><td><code>type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The type of upscale. Can be "2x" or "4x".</td></tr><tr><td><code>index</code></td><td>string</td><td>The index of the image to upscale. Can be 1, 2, 3 or 4<br>Only needed if it's a 4 generated images task.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "image_url": "https://............./xxxxx.png",
    "task_type": "upscale-2x"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "upscale-2x",
    "status": "processing",
    "percentage": "80",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "4x"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/upscale-highres',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/upscale-highres"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "4x"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/upscale-highres',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "type": "4x"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"type\": \"4x\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/upscale-highres")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "4x"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/upscale-highres',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upscale-highres");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"type\": \"4x\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/upscale-highres")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "type": "4x"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Variations

Create 4 new variations of one of the 4 generated images by the Imagine request.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/variations`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>index</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The index of the image to create variations from. Can be 1, 2, 3 or 4<br><br>Can also be "strong" or "subtle", take a look <a href="https://docs.midjourney.com/docs/variations">here</a></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "variation-1",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "variation-1",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/variations',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/variations"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/variations',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "index": "2"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"index\": \"2\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/variations")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/variations',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/variations");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"index\": \"2\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/variations")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "index": "2"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Faceswap

Swap the face on a target image with the face on a provided image. Each image must contain only one face.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/faceswap`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="230">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>target_image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The URL of the image where the face will be swapped</td></tr><tr><td><code>swap_image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The url of the image where the new face should be taken from.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "image_url": "https://............./xxxxx.png",
    "task_type": "faceswap"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "faceswap",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "target_image_url": "https://xxxxxxxxxxxxxxxxx/target.png",
  "swap_image_url": "https://xxxxxxxxxxxxxxxxx/swap.png"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/faceswap',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/faceswap"

payload = json.dumps({
  "target_image_url": "https://xxxxxxxxxxxxxxxxx/target.png",
  "swap_image_url": "https://xxxxxxxxxxxxxxxxx/swap.png"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/faceswap',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "target_image_url": "https://xxxxxxxxxxxxxxxxx/target.png",
    "swap_image_url": "https://xxxxxxxxxxxxxxxxx/swap.png"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"target_image_url\": \"https://xxxxxxxxxxxxxxxxx/target.png\",\r\n    \"swap_image_url\": \"https://xxxxxxxxxxxxxxxxx/swap.png\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/faceswap")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "target_image_url": "https://xxxxxxxxxxxxxxxxx/target.png",
  "swap_image_url": "https://xxxxxxxxxxxxxxxxx/swap.png"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/faceswap',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/faceswap");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"target_image_url\": \"https://xxxxxxxxxxxxxxxxx/target.png\",\r\n    \"swap_image_url\": \"https://xxxxxxxxxxxxxxxxx/swap.png\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/faceswap")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "target_image_url": "https://xxxxxxxxxxxxxxxxx/target.png",
  "swap_image_url": "https://xxxxxxxxxxxxxxxxx/swap.png"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Inpaint (Vary Region)

Redraw a selected area of an image. Of course you first need to Upscale 1x.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/inpaint`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>mask</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Base64 encoding of the image corresponding to the selected area</td></tr><tr><td><code>prompt</code></td><td>string</td><td>Drawing prompt for selected areas</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

You can use our [Inpaint Mask Tool](https://github.com/APIFRAME-PRO/inpaint-mask-tool) to get the base64 mask.

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "inpaint",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "inpaint",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "mask": "data:image/png;base64,...........",
  "prompt": "a bird"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/inpaint',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/inpaint"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "mask": "data:image/png;base64,...........",
  "prompt": "a bird"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/inpaint',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "mask": "data:image/png;base64,...........",
    "prompt": "a bird"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"mask\": \"data:image/png;base64,...........\",\r\n    \"prompt\": \"a bird\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/inpaint")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "mask": "data:image/png;base64,...........",
  "prompt": "a bird"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/inpaint',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/inpaint");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"mask\": \"data:image/png;base64,...........\",\r\n    \"prompt\": \"a bird\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/inpaint")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "mask": "data:image/png;base64,...........",
  "prompt": "a bird"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Outpaint (Zoom Out)

The outpaint endpoint enlarges an image's canvas beyond its original size while keeping the contents of the original image unchanged. Of course you first need to Upscale 1x.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/outpaint`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>zoom_ratio</code><mark style="color:red;"><code>*</code></mark></td><td>number</td><td><p></p><p>Can be:</p><ul><li>1.5 for MJ button "zoom out 1.5x"</li><li>2 for MJ button "zoom out 2x"</li><li>(1, 2] for MJ button "custom zoom"</li><li>1 for MJ button "make square"</li></ul><p>You can take a look <a href="https://docs.midjourney.com/docs/zoom-out">here</a></p></td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio of the image default value 1:1</td></tr><tr><td><code>prompt</code></td><td>string</td><td>Drawing prompt for new areas</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "outpaint-2",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "outpaint-2",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "zoom_ratio": "2"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/outpaint',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/outpaint"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "zoom_ratio": "2"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/outpaint',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "zoom_ratio": "2"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"zoom_ratio\": \"2\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/outpaint")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "zoom_ratio": "2"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/outpaint',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/outpaint");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"zoom_ratio\": \"2\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/outpaint")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "zoom_ratio": "2"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Pan

Broadens the image canvas in a specific direction, keeping the original content intact and using prompts and the original image as guides for filling the expanded area. You first need to Upscale 1x

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/pan`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task ID of the original task</td></tr><tr><td><code>direction</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td><p>Image expansion direction.</p><p>Can be: "up", "down", "left" or "right"</p></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "pan-up",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "pan-up",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "direction": "up",
  "prompt": "a blue sky"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/pan',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/pan"

payload = json.dumps({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "direction": "up",
  "prompt": "a blue sky"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/pan',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "direction": "up",
    "prompt": "a blue sky"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"direction\": \"up\",\r\n    \"prompt\": \"a blue sky\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/pan")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "direction": "up",
  "prompt": "a blue sky"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/pan',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/pan");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\",\r\n    \"direction\": \"up\",\r\n    \"prompt\": \"a blue sky\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/pan")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "direction": "up",
  "prompt": "a blue sky"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Shorten

This analyzes your prompt, highlights some of your prompt's most influential words, and suggests unnecessary words you could remove. You can then optimize your prompt by focusing on essential terms.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/shorten`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for Midjourney AI</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate results instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "shorten",
    "content": ["1️⃣...", "2️⃣...", "3️⃣..."],
    "full_content": "## Important tokens\n..."
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "shorten",
    "status": "starting"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/shorten',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/shorten"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/shorten',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/shorten")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/shorten',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/shorten");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/shorten")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Describe

Writes four example prompts based on an image you upload. This is the same as using the /describe command in Discord.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/describe`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The URL of the image you want to describe. Should be accessible on Internet.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate results instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "describe",
    "image_url": "https://...............xx.png",
    "content": [
    "1️⃣ a red....",
    "2️⃣ a dog....",
    "3️⃣ a red dog....",
    "4️⃣ dog and ...."
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "describe",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "image_url": "https://...............xx.png"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/describe',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/describe"

payload = json.dumps({
  "image_url": "https://...............xx.png"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/describe',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "image_url": "https://...............xx.png"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"image_url\": \"https://...............xx.png\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/describe")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "image_url": "https://...............xx.png"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/describe',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/describe");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"image_url\": \"https://...............xx.png\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/describe")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "image_url": "https://...............xx.png"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Blend

Blend multiple images into one image.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/blend`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image_urls</code><mark style="color:red;"><code>*</code></mark></td><td>[string]</td><td>The URLs of the images to blend. Min 2, max 5</td></tr><tr><td><code>dimension</code></td><td>string</td><td>Can be "square", "portrait" or "landscape". "square" by default.<br>Take a look <a href="https://docs.midjourney.com/docs/blend">here</a></td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "blend",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_urls": [
        "https://.../xxxx1.png",
        "https://.../xxxx2.png",
        "https://.../xxxx3.png",
        "https://.../xxxx4.png"
    ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "blend",
    "status": "processing",
    "percentage": "80"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "image_urls": [
    "https://...............xx1.png",
    "https://...............xx2.png",
    "https://...............xx3.png"
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/blend',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/blend"

payload = json.dumps({
  "image_urls": [
    "https://...............xx1.png",
    "https://...............xx2.png",
    "https://...............xx3.png"
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/blend',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "image_urls": ["https://...............xx1.png", "https://...............xx2.png", "https://...............xx3.png"]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"image_urls\": [\"https://...............xx1.png\", \"https://...............xx2.png\", \"https://...............xx3.png\"]\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/blend")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "image_urls": [
    "https://...............xx1.png",
    "https://...............xx2.png",
    "https://...............xx3.png"
  ]
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/blend',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/blend");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"image_urls\": [\"https://...............xx1.png\", \"https://...............xx2.png\", \"https://...............xx3.png\"]\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/blend")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "image_urls": [
    "https://...............xx1.png",
    "https://...............xx2.png",
    "https://...............xx3.png"
  ]
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Seed

Get the seed of a generated image.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/seed`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task_id of the task</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate results instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "seed",
    "seed": "993456789123"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "seed",
    "status": "processing"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/seed',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import http.client
import json

conn = http.client.HTTPSConnection("api.apiframe.pro")
payload = json.dumps({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}
conn.request("POST", "/seed", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/seed',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/seed")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/seed',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/seed");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/seed")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Fetch

Get the result/status of a submitted task.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/fetch`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The task_id of the task</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  // The data depends on the type of the original request
  // You can see the different results on each endpoint page
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/fetch',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/fetch"

payload = json.dumps({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/fetch',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/fetch")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/fetch',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/fetch");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"task_id\": \"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/fetch")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Fetch Many

Get the results/statuses of multiple tasks using their task\_id.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/fetch-many`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>task_ids</code><mark style="color:red;"><code>*</code></mark></td><td>[string]</td><td>The task id of the tasks, min 2 and max 20</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{ 
    tasks: [
        // An array of results/statuses
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "task_ids": [
    "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4",
    "8274fd0f-259b-42e3-af07-4ac6d4ab7c6e"
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/fetch-many',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/fetch-many"

payload = json.dumps({
  "task_ids": [
    "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4",
    "8274fd0f-259b-42e3-af07-4ac6d4ab7c6e"
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/fetch-many',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "task_ids": ["29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a", "71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4", "8274fd0f-259b-42e3-af07-4ac6d4ab7c6e"]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"task_ids\": [\"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\", \"71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4\", \"8274fd0f-259b-42e3-af07-4ac6d4ab7c6e\"]\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/fetch-many")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "task_ids": [
    "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4",
    "8274fd0f-259b-42e3-af07-4ac6d4ab7c6e"
  ]
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/fetch-many',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/fetch-many");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"task_ids\": [\"29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a\", \"71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4\", \"8274fd0f-259b-42e3-af07-4ac6d4ab7c6e\"]\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/fetch-many")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "task_ids": [
    "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "71cfa6bd-f0d2-4f0c-b11d-56f256fc55a4",
    "8274fd0f-259b-42e3-af07-4ac6d4ab7c6e"
  ]
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Account Info

Get details about your account: credits remaining, stats, etc..

<mark style="color:green;">`GET`</mark>` ``https://api.apiframe.pro/account`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "email": "coolme@coolw.com",
  "credits": 12000,
  "total_images": 695,
  "plan": "starter"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/account',
  headers: { 
    'Authorization': 'YOUR_API_KEY'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.apiframe.pro/account"

payload = {}
headers = {
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/account',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/account")
  .method("GET", body)
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Authorization': 'YOUR_API_KEY'
};
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/account',
  options: Options(
    method: 'GET',
    headers: headers,
  ),
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.apiframe.pro/account");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.apiframe.pro/account")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "YOUR_API_KEY"

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Statuses

Here are the different possible statuses for a task

* pending:  The task is waiting to be executed in the queue.
* staged:  The task is cached, not in the queue yet.
* starting: The task is beginning to proceed.
* processing: The task is being executed.
* finished: The task has been completed.
* failed: The task execution failed.
* retry/retrying: The task is waiting in the queue to be retried.


# Postman Collection

The postman collection is available at <https://documenter.getpostman.com/view/33976547/2sA35HXgaH>


# AI Photos

Generate hyper realistic photos of human subjects.


# Upload and Prepare

Upload 10 to 30 images of the subject and prepare them for AI training.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ai-photo-upload`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>images</code><mark style="color:red;"><code>*</code></mark></td><td>[string]</td><td>Base64 of 10 to 30 images, to use for AI training.<br>Take a look <a href="/pages/1XVS0tUURMKMG0Flcb2K">here for best input images</a>.</td></tr><tr><td><code>ethnicity</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Subject ethnicity, one of 'asian', 'black', 'latino', 'middle eastern', 'native american', 'pacific islander', or 'white'</td></tr><tr><td><code>gender</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Subject gender, one of 'female' or 'male'</td></tr><tr><td><code>age</code></td><td>integer</td><td>The age of the subject</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate results instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "status": "finished",
    "message": "Images ready for training",
    "expires_at": "2025-02-21T05:48:46.599Z"
}
```

If the job is not completed, you will get a result like this:

```json
{
   "status": "processing",
   "message": 'Training images are being processed'
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "images": [],
  "ethnicity": "asian",
  "gender": "female",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ai-photo-upload',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ai-photo-upload"

payload = json.dumps({
  "images": [],
  "ethnicity": "asian",
  "gender": "female",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ai-photo-upload',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "images": [],
    "ethnicity": "asian",
    "gender": "female",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"images\": \[ \],\r\n   \"ethnicity\": \"asian\",\r\n  \"gender\": \"female\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ai-photo-upload")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "images": [],
  "ethnicity": "asian",
  "gender": "female",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ai-photo-upload',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ai-photo-upload");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n  \"images\": \[ \],\r\n   \"ethnicity\": \"asian\",\r\n  \"gender\": \"female\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ai-photo-upload")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "images": [],
  "ethnicity": "asian",
  "gender": "female",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Train

Train AI on a human subject using previously uploaded and prepared images.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ai-photo-train`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>training_images_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the task_id of the 'ai-photo-upload' corresponding task </td></tr><tr><td><code>trigger_word</code></td><td>string</td><td>A trigger word that will be used as a reference to the Subject to generate images. By default "TOKMSN"</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate results instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "3492deb6-d98a-4c4f-895c-e215ec7508f6",
    "status": "finished", 
    "message": "Training finished, you can generate photos now!", 
    "percentage": 100, 
    "trigger_word": "TOKIKD"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "message": "Training is in progress",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "training_images_id": "...",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ai-photo-train',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ai-photo-train"

payload = json.dumps({
  "training_images_id": "...",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ai-photo-train',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "training_images_id": "...",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"training_images_id\": \"...\",\r\n   \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ai-photo-train")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "training_images_id": "...",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ai-photo-train',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ai-photo-train");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"training_images_id\": \"...\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ai-photo-train")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "training_images_id": "...",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Generate

Generate realistic photos of the subject using the trained model.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ai-photo-generate`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>training_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the task_id of the corresponding training task</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt to describe the photo to generate<br><br>Ex: a realistic portrait of TOKMSN black man wearing a suit</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td><p>Aspect ratio for the image, one of '1:1', '4:3', '3:4', '16:9', '9:16', '3:2', '2:3', '21:9', '9:21', '5:4', '4:5', '1:2', '2:1', '1:3', '3:1', '1:4', '4:1', or 'custom'</p><p>Default: 1:1<br><br>Needs to be 'custom' if you provide height and width</p></td></tr><tr><td><code>width</code></td><td>string</td><td>The width of the images<br><br>The aspect_ratio needs to be custom for this</td></tr><tr><td><code>height</code></td><td>string</td><td>The height of the images<br><br>The aspect_ratio needs to be custom for this</td></tr><tr><td><code>number_of_images</code></td><td>string</td><td>Number of images to generate: 1 to 4</td></tr><tr><td><code>seed</code></td><td>integer</td><td>The seed for the generation</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the image has been generated
{
  "task_id": "82ddc894-7c88-48d8-8f65-63101c3c88fc",
  "status": "finished",
  "task_type": "ai-photo-generate",
  "image_urls": [
    "https://cdn.apiframe.pro/images/xxxxxxxxxxxxx-0.png",
    "https://cdn.apiframe.pro/images/xxxxxxxxxxxxx-1.png"
  ]
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "training_id": "...",
  "prompt": "a portrait of TOKMSN Asian female..",
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ai-photo-generate',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ai-photo-generate"

payload = json.dumps({
  "training_id": "...",
  "prompt": "a portrait of TOKMSN Asian female..",
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ai-photo-generate',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "training_id": "...",
    "prompt": "a portrait of TOKMSN Asian female..",
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"training_id\": \"...\",  \"prompt\": \"a portrait of TOKMSN Asian female..\",\r\n   }");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ai-photo-generate")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "training_id": "...",
  "prompt": "a portrait of TOKMSN Asian female..",
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ai-photo-generate',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ai-photo-generate");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"training_id\": \"...\", \"prompt\": \"a portrait of TOKMSN Asian female..\", \r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ai-photo-generate")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "training_id": "...",
  "prompt": "a portrait of TOKMSN Asian female..",
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Best Input Images

To get the best results, your input images should be:

* **High quality**: Use clear, well-lit images with good resolution (ideally 1024×1024 or higher)
* **Diverse in composition**: Include various poses, expressions, angles, and outfits
* **Consistent in subject**: Ensure all images feature the same person
* **Clean background**: Simpler backgrounds help the model focus on the subject
* **Well-cropped**: Center the subject and avoid unnecessary elements
* **Varied in framing**: Mix of close-ups, mid-shots, and full-body images
* **Consistent in style**: Similar lighting and color grading across images
* **Free of watermarks/text**: These can confuse the model
* **Adequate quantity**: 15-30 high-quality images typically work better than 100+ low-quality ones


# IDEOGRAM


# Imagine

Generate an image using a text prompt.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ideogram-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt to describe the image to generate</td></tr><tr><td><code>style_type</code></td><td>string</td><td>The style for the image; it can be 'GENERAL', 'REALISTIC', 'DESIGN', 'RENDER_3D', or 'ANIME'<br>'GENERAL' by default.</td></tr><tr><td><code>negative_prompt</code></td><td>string</td><td>Describe what you don't want</td></tr><tr><td><code>seed</code></td><td>integer</td><td>The seed for the generation</td></tr><tr><td><code>magic_prompt_option</code></td><td>string</td><td>It can be 'AUTO', 'ON', or 'OFF'<br>'AUTO' by default.</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the image in this format 'ASPECT_X_Y' Default: ASPECT_1_1<br><br>One of the aspect ratio or the resolution is needed, not both.</td></tr><tr><td><code>resolution</code></td><td>string</td><td>The resolution for the image in this format 'RESOLUTION_W_H'<br>Ex: RESOLUTION_1024_1024<br><br>One of the aspect ratio or the resolution is needed, not both.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the image has been generated
{
    "task_id": "64cd7965-1b78-42c8-b929-9d7751a2e149",
    "image_urls": [
      "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxx.png"
    ],
    "status": "finished",
    "task_type": "ideogram-imagine",
    "seed": 12345
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ideogram-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ideogram-imagine"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ideogram-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n   }");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ideogram-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ideogram-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ideogram-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ideogram-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Remix

Generate an image using a text prompt.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ideogram-remix`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the url of the image to remix</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt to describe the image to generate</td></tr><tr><td><code>image_weight</code><mark style="color:red;"><code>*</code></mark></td><td>integer</td><td>an integer between 1 and 100</td></tr><tr><td><code>style_type</code></td><td>string</td><td>The style for the image; it can be 'GENERAL', 'REALISTIC', 'DESIGN', 'RENDER_3D', or 'ANIME'<br>'GENERAL' by default.</td></tr><tr><td><code>negative_prompt</code></td><td>string</td><td>Describe what you don't want</td></tr><tr><td><code>seed</code></td><td>integer</td><td>The seed for the generation</td></tr><tr><td><code>magic_prompt_option</code></td><td>string</td><td>It can be 'AUTO', 'ON', or 'OFF'<br>'AUTO' by default.</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the image in this format 'ASPECT_X_Y' Default: ASPECT_1_1<br><br>One of the aspect ratio or the resolution is needed, not both.</td></tr><tr><td><code>resolution</code></td><td>string</td><td>The resolution for the image in this format 'RESOLUTION_W_H'<br>Ex: RESOLUTION_1024_1024<br><br>One of the aspect ratio or the resolution is needed, not both.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the image has been generated
{
    "task_id": "64cd7965-1b78-42c8-b929-9d7751a2e149",
    "image_urls": [
      "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxx.png"
    ],
    "status": "finished",
    "task_type": "ideogram-remix",
    "seed": 12345
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "image_weight": 50,
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ideogram-remix',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ideogram-remix"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "image_weight": 50,
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ideogram-remix',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind",
    "image_url": "https://.....................x.png",
    "image_weight": 50,
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"image_weight\": 50,\r\n    \"image_url\": \"https://........x.png\",\r\n }");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ideogram-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "image_weight": 50,
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ideogram-remix',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ideogran-remix");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"image_weight\": 50,\r\n    \"image_url\": \"https://.........x.png\",\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ideogram-remix")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "image_weight": 50,
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Upscale

Upscale an existing image to a higher quality and resolution.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/ideogram-upscale`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the url of the image to remix</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt to describe the image to generate</td></tr><tr><td><code>resemblance</code><mark style="color:red;"><code>*</code></mark></td><td>integer</td><td>an integer between 1 and 100</td></tr><tr><td><code>detail</code></td><td>integer</td><td>an integer between 1 and 100</td></tr><tr><td><code>seed</code></td><td>integer</td><td>The seed for the generation</td></tr><tr><td><code>magic_prompt_option</code></td><td>string</td><td>It can be 'AUTO', 'ON', or 'OFF'<br>'AUTO' by default.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the image has been generated
{
    "task_id": "64cd7965-1b78-42c8-b929-9d7751a2e149",
    "image_urls": [
      "https://cdn.apiframe.pro/images/xxxxxxxxxxxxxx.png"
    ],
    "status": "finished",
    "task_type": "ideogram-upscale",
    "seed": 12345
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "resemblance": 50,
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ideogram-upscale',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ideogram-upscale"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "resemblance": 50,
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ideogram-upscale',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind",
    "image_url": "https://.....................x.png",
    "resemblance": 50,
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"resemblance\": 50,\r\n    \"image_url\": \"https://........x.png\",\r\n }");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ideogram-upscale")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "resemblance": 50,
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ideogram-upscale',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ideogram-upscale");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n    \"resemblance\": 50,\r\n    \"image_url\": \"https://.........x.png\",\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ideogram-upscale")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind",
  "image_url": "https://.....................x.png",
  "resemblance": 50,
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Describe

Extensively describe the provided image.

<mark style="color:green;">`POST`</mark>` ``https://api.apiframe.pro/describe`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="219">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>image_url</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The URL of the image you want to describe. Should be accessible on Internet.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "status": "finished",
  "task_type": "ideogram-describe",
  "description": "A vibrant blue bird perched on a thin wire. The bird has a sharp beak, a round eye, and its feathers exhibit a gradient of blue hues. The background is blurred, emphasizing the bird, and appears to be an outdoor setting with a neutral color palette."
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "image_url": "https://...............xx.png"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/ideogram-describe',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/ideogram-describe"

payload = json.dumps({
  "image_url": "https://...............xx.png"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/ideogram-describe',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "image_url": "https://...............xx.png"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"image_url\": \"https://...............xx.png\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/ideogram-describe")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "image_url": "https://...............xx.png"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/ideogram-describe',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/ideogram-describe");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"image_url\": \"https://...............xx.png\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/ideogram-describe")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "image_url": "https://...............xx.png"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# FLUX

Generate high accuracy images with Flux models from Black Forest Labs


# Imagine

Generate an image using a text prompt and an image.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/flux-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="206">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>model</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The model to use for the generation; It can be 'flux-schnell', 'flux-pro', 'flux-dev', 'flux-pro-1.1', or 'flux-pro-1.1-ultra'</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt to describe the image to generate</td></tr><tr><td><code>image_prompt</code></td><td>string</td><td>Optional base64 encoded image to use for image-to-image</td></tr><tr><td><code>image_prompt_strength</code></td><td>float</td><td>Should be a float between 0 and 1<br>Only for 'flux-pro-1.1-ultra'</td></tr><tr><td><code>prompt_upsampling</code></td><td>boolean</td><td>Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation.</td></tr><tr><td><code>width</code></td><td>integer</td><td>The width of the image to generate, min 256 and max 1440. Default: 1024</td></tr><tr><td><code>height</code></td><td>integer</td><td>The height of the image to generate, min 256 and max 1440. Default: 768</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio of the image between 21:9 and 9:21<br>Default: 16:9<br>Only for flux-pro-1.1-ultra'</td></tr><tr><td><code>steps</code></td><td>integer</td><td>Number of steps for the image generation process. Only for 'flux-pro' and 'flux-dev'</td></tr><tr><td><code>guidance</code></td><td>float</td><td>Guidance scale for image generation. High guidance scales improve prompt adherence at the cost of reduced realism.<br>Only for 'flux-pro' and 'flux-dev'</td></tr><tr><td><code>interval</code></td><td>integer</td><td>Interval parameter for guidance control. Default: 2<br>Min: 1, Max: 4<br>Only for 'flux-pro'</td></tr><tr><td><code>seed</code></td><td>integer</td><td>The seed to use for the generation</td></tr><tr><td><code>safety_tolerance</code></td><td>integer</td><td>Tolerance level for input and output moderation. Between 0 and 6, 0 being most strict, 6 being least strict.</td></tr><tr><td><code>raw</code></td><td>boolean</td><td>Generate less processed, more natural-looking images<br>Only for flux-pro-1.1-ultra'</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
    "task_id": "64cd7965-1b78-42c8-b929-9d7751a2e149"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate images instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "flux-imagine",
    "original_image_url": "https://.../xxxxxxxx.png", // grid image
    "image_url": "https://.../xxxxxxxx.png"
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "flux-imagine",
    "status": "processing",
    "percentage": 40
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a sunflower field in the wind",
  "model": "flux-pro"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/flux-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/flux-imagine"

payload = json.dumps({
  "prompt": "a sunflower field in the wind",
  "model": "flux-pro"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/flux-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a sunflower field in the wind",
    "model": "flux-pro"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a sunflower field in the wind\",\r\n  \"model\": \"flux-pro\",\r\n   }");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/flux-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a sunflower field in the wind",
  "model": "flux-pro"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/flux-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/flux-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a sunflower field in the wind\"    \"model\": \"flux-pro\" \r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/flux-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a sunflower field in the wind",
  "model": "flux-pro"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# LUMA AI API

This service allows you to interact with one of the most advanced video generation model: Luma Dream Machine.


# IMAGINE

Generate a video based on a prompt and/or an image input.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/luma-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="191">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for the video</td></tr><tr><td><code>image_url</code></td><td>string</td><td>URL of the image representing initial frame of the video</td></tr><tr><td><code>end_image_url</code></td><td>string</td><td>URL of the image representing end frame of the video</td></tr><tr><td><code>enhance_prompt</code></td><td>boolean</td><td>Should Luma AI try to enhance your prompt? Default: false</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the video. Default: 1:1</td></tr><tr><td><code>loop</code></td><td>boolean</td><td>Create a looping video</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "luma",
    "video_url": "https://...........xxxx.mp4", // 
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "luma",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/luma-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/luma-imagine"

payload = json.dumps({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/luma-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"aspect_ratio\": \"3:2\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/luma-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/luma-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/luma-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/luma-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# EXTEND

Extend a previously generated video based on a prompt and/or an image input.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/luma-extend`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="209">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>The ID of the original task</td></tr><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for the video</td></tr><tr><td><code>image_url</code></td><td>string</td><td>URL of the image representing initial frame of the video</td></tr><tr><td><code>end_image_url</code></td><td>string</td><td>URL of the image representing end frame of the video</td></tr><tr><td><code>enhance_prompt</code></td><td>boolean</td><td>Should Luma AI try to enhance your prompt? Default: false</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the video. Default: 1:1</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "luma-ext",
    "video_url": "https://...........xxxx.mp4", // 
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "luma-ext",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "parent_task_id": "xxxxxxxxxx",
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/luma-extend',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

<pre class="language-python"><code class="lang-python">import requests
import json

url = "https://api.apiframe.pro/luma-extend"

payload = json.dumps({
<strong>  "parent_task_id": "xxxxxxxxxx",
</strong>  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

</code></pre>

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/luma-extend',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "xxxxxxxxxx",
    "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n  \"parent_task_id\": \"xxxxxxxxxx\",   \r\n   \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"aspect_ratio\": \"3:2\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/luma-extend")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "xxxxxxxxxx",
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/luma-extend',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/luma-extend");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"xxxxxxxxxx\",   \r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/luma-extend")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "xxxxxxxxxx",
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# SUNO AI API

This service allows you to interact with one of the most advanced music generation model: SUNO AI.


# IMAGINE

Generate a song with a lyrics video clip. You have access to the chirp-v3-0 and chirp-v3-5 models. This endpoint actually generates two songs with the same lyrics.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/suno-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="237">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>string</td><td>the text prompt for Suno AI, just describe the song. Only needed if the lyrics field is not submitted</td></tr><tr><td><code>lyrics</code></td><td>string</td><td>lyrics for the song to generate, only needed if the prompt is not submitted</td></tr><tr><td><code>model</code></td><td>string</td><td>The music generation model to use. Accepted values: <code>V4</code>, <code>V4_5</code>, <code>V4_5PLUS</code>, <code>V4_5ALL</code>, <code>V5</code>. Legacy aliases are also supported:  <code>chirp-v4</code> (maps to <code>V4</code>), <code>chirp-auk</code> (maps to <code>V4_5</code>), <code>chirp-bluejay</code> (maps to <code>V4_5PLUS</code>), <code>chirp-crow</code> (maps to <code>V5</code>).</td></tr><tr><td><code>make_instrumental</code></td><td>boolean</td><td>Use <code>true</code> to Generate instrumental without lyrics</td></tr><tr><td><code>title</code></td><td>string</td><td>a title for the song</td></tr><tr><td><code>tags</code></td><td>string</td><td>style tags for the song, ex: 'rap pop'</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the songs instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "suno",
    "status": "finished",
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      }
  ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "suno",
    "status": "processing",
    "percentage": 56,
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": null
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": null
      }
  ]
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/suno-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/suno-imagine"

payload = json.dumps({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/suno-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a true friend",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a true friend\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/suno-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/suno-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/suno-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a true friend\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/suno-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# UPLOAD

Upload an audio file and get an audio url (don't need it if you already have an audio url).

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/suno-upload`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `multipart/form-data` |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="237">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>audio</code><mark style="color:red;"><code>*</code></mark></td><td>binary</td><td>The audio file you want to upload. Maximum 10MB.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success: the audio was turned into a song
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
  "audio_url": "https://cdn.apiframe.pro/songs/xxxxxxxxxxxxxxxxxxx.mp3"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('audio', fs.createReadStream('..../audio.mp4'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/suno-upload',
  headers: { 
    'Authorization': 'YOUR_API_KEY', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.apiframe.pro/suno-upload"

payload = {}
files=[
  ('image',('audio.mp4',open('..../audio.mp4','rb'),'audio/mp4'))
]
headers = {
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/suno-upload',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('audio'=> new CURLFILE('..../audio.mp4')),
  CURLOPT_HTTPHEADER => array(
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("audio","",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("..../audio.mp4")))
  .build();
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/suno-upload")
  .method("POST", body)
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Authorization': 'YOUR_API_KEY'
};
var data = FormData.fromMap({
  'files': [
    await MultipartFile.fromFile('..../audio.mp4', filename: '')
  ],

});

var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/suno-upload',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/suno-upload");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("..../audio.mp4")), "audio", "zlpGHQ2ic/Audio.mp4");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.apiframe.pro/suno-upload")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "YOUR_API_KEY"
form_data = [['audio', File.open('.../audio.mp4')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# EXTEND

Extend a previously generated song or an uploaded audio.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/suno-extend`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="237">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>parent_task_id</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the id of the original suno task</td></tr><tr><td><code>song_id</code></td><td>string</td><td>the song_id of one of the two generated songs to extend. Not needed when you are extending an uploaded audio.</td></tr><tr><td><code>continue_at</code></td><td>float</td><td>The timestamp from where the song should be extended</td></tr><tr><td><code>prompt</code></td><td>string</td><td>the text prompt for Suno AI, just describe the song. </td></tr><tr><td><code>model</code></td><td>string</td><td>The music generation model to use. Accepted values: <code>V4</code>, <code>V4_5</code>, <code>V4_5PLUS</code>, <code>V4_5ALL</code>, <code>V5</code>. Legacy aliases are also supported:  <code>chirp-v4</code> (maps to <code>V4</code>), <code>chirp-auk</code> (maps to <code>V4_5</code>), <code>chirp-bluejay</code> (maps to <code>V4_5PLUS</code>), <code>chirp-crow</code> (maps to <code>V5</code>).</td></tr><tr><td><code>lyrics</code></td><td>string</td><td>lyrics for the song to generate</td></tr><tr><td><code>title</code></td><td>string</td><td>a title for the song</td></tr><tr><td><code>tags</code></td><td>string</td><td>style tags for the song, ex: 'rap pop'</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final results of this task and updates will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the songs instantly; you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "suno",
    "status": "finished",
    "video_url": "https://...........xxxx.mp4",
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      }
  ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "suno",
    "status": "processing",
    "percentage": 56,
    "video_url": "https://...........xxxx.mp4",
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
        "video_url": "https://....xxxxxxxxx.mp4"
      }
  ]
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "parent_task_id": "xxxxxxxxx",
  "song_id": "xxxxxxxxxx",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/suno-extend',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/suno-extend"

payload = json.dumps({
  "parent_task_id": "xxxxxxxxx",
  "song_id": "xxxxxxxxxx",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/suno-extend',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "parent_task_id": "xxxxxxxxx",
    "song_id": "xxxxxxxxxx",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"parent_task_id\": \"xxxxxxxxxxx\",\r\n    \"song_id\": \"xxxxxxxxxxx\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/suno-extend")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "parent_task_id": "xxxxxxxxx",
  "song_id": "xxxxxxxxxx",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/luma-extend',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/suno-extend");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"parent_task_id\": \"xxxxxxxxxxx\",\r\n    \"song_id\": \"xxxxxxxxxxx\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/suno-extend")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "parent_task_id": "xxxxxxxxx",
  "song_id": "xxxxxxxxxx",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# LYRICS

Generate song Lyrics based on a prompt.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/suno-lyrics`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="237">Name</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for generating the lyrics</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This request takes about 10 secs. The result looks like this:

```json
{
  "type": "suno-lyrics",
  "title": "xxxxxxxx",
  "lyrics": "xxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "finished"
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a true friend"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/suno-lyrics',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/suno-lyrics"

payload = json.dumps({
  "prompt": "a true friend"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/suno-lyrics',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a true friend"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a true friend\",\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/suno-lyrics")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a true friend"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/luma-lyrics',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/suno-lyrics");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a true friend\",\r\n }", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/suno-lyrics")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a true friend"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# UDIO AI API

Generate great music songs with Udio


# Generate a song

Generate a song using Udio AI.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/udio-generate`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="239">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:$danger;"><code>*</code></mark></td><td>string</td><td>Description/style for the song (e.g., "night breeze, piano", "jazz, pop"). Max 2000 characters.</td></tr><tr><td><code>lyrics</code></td><td>string</td><td>Full lyrics when lyrics_type is "user". Max 5000 characters.</td></tr><tr><td><code>lyrics_type</code></td><td>string</td><td><strong>generate</strong> (AI writes lyrics), <strong>user</strong> (use provided lyrics), or <strong>instrumental</strong> (no lyrics). Default: generate</td></tr><tr><td><code>negative_tags</code></td><td>string</td><td>Tags to avoid, comma-separated (e.g., "pop,rock"). Max 500 characters.</td></tr><tr><td><code>seed</code></td><td>string</td><td>Seed for reproducibility. Use -1 for random.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the songs instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-generate",
    "status": "finished",
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
      }
  ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-generate",
    "status": "processing",
    "percentage": 56,
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": null",
        "image_url": "https://....xxxxxxxxx.jpeg",
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": null,
        "image_url": "https://....xxxxxxxxx.jpeg",
      }
  ]
}
```


# Extend a song

Extend an existing Udio song by adding more content.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/udio-extend`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="239">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:$danger;"><code>*</code></mark></td><td>string</td><td>Description/style for the song (e.g., "night breeze, piano", "jazz, pop"). Max 2000 characters.</td></tr><tr><td><code>continue_song_id</code><mark style="color:$danger;"><code>*</code></mark></td><td>string</td><td>The Udio song ID to extend (from a previous generation).</td></tr><tr><td><code>continue_at</code></td><td>integer</td><td>Timestamp in seconds where to start the extension. Default: 0</td></tr><tr><td><code>lyrics</code></td><td>string</td><td>Full lyrics when lyrics_type is "user". Max 5000 characters.</td></tr><tr><td><code>lyrics_type</code></td><td>string</td><td><strong>generate</strong> (AI writes lyrics), <strong>user</strong> (use provided lyrics), or <strong>instrumental</strong> (no lyrics). Default: generate</td></tr><tr><td><code>negative_tags</code></td><td>string</td><td>Tags to avoid, comma-separated (e.g., "pop,rock"). Max 500 characters.</td></tr><tr><td><code>seed</code></td><td>string</td><td>Seed for reproducibility. Use -1 for random.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the songs instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-extend",
    "status": "finished",
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": "https://....xxxxxxxxx.mp3",
        "image_url": "https://....xxxxxxxxx.jpeg",
      }
  ]
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-extend",
    "status": "processing",
    "percentage": 56,
    "songs": [
      {
        "lyrics": "....",
        "song_id": "ea6813ad-03ce-4a0b-a616-xxxxxxxxx",
        "audio_url": null",
        "image_url": "https://....xxxxxxxxx.jpeg",
      },
      {
        "lyrics": "...",
        "song_id": "21ad7efc-4954-4ae4-ae2a-xxxxxxxx",
        "audio_url": null,
        "image_url": "https://....xxxxxxxxx.jpeg",
      }
  ]
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/udio-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/udio-imagine"

payload = json.dumps({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/udio-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "a true friend",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"a true friend\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/udio-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/udio-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/udio-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"a true friend\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/udio-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "a true friend",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# Generate Lyrics

Generate song lyrics using Udio AI.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/udio-lyrics`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="239">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:$danger;"><code>*</code></mark></td><td>string</td><td>Theme or guidance for lyrics generation (e.g., "White egrets fly over the vast paddy fields"). Max 2000 characters.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the songs instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-lyrics",
    "status": "finished",
    "lyrics": "..."
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-xxxxxxxxx",
    "task_type": "udio-lyrics",
    "status": "processing",
    "percentage": 56
}
```


# RUNWAY ML API

Generate realistic videos with Runway ML


# IMAGINE

Generate a video based on a prompt and/or an image input or a video input.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/runway-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>the text prompt for the video</td></tr><tr><td><code>generation_type</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>It can be 'text2video', 'image2video' or 'video2video'</td></tr><tr><td><code>image_url</code></td><td>string</td><td>URL of the image representing the initial frame of the video, for 'image2video'</td></tr><tr><td><code>end_image_url</code></td><td>string</td><td>URL of the image representing the end frame of the video, also for 'image2video'</td></tr><tr><td><code>video_url</code></td><td>string</td><td>The video to use for the 'video2video' generation</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Aspect ratio for the video. Can be 16:9, 9:16, 1:1, 4:3, 3:4, or 21:9<br>Only for 'text2video'</td></tr><tr><td><code>model</code></td><td>string</td><td>The model to use to generate the video, it can be 'gen3' or 'gen3a_turbo'</td></tr><tr><td><code>duration</code></td><td>integer</td><td>The duration of the video, it can be 5 or 10</td></tr><tr><td><code>flip</code></td><td>boolean</td><td>Whether to flip the video vertically or not</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "runway",
    "video_url": "https://...........xxxx.mp4", // 
    "status": "finished",
    "percentage": 100
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "runway",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "generation_type": "text2video",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/runway-imagine',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/runway-imagine"

payload = json.dumps({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "generation_type": "text2video",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/runway-imagine',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
    "generation_type": "text2video",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"generation_type\": \"text2video\",\r\n     \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/runway-imagine")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "generation_type": "text2video",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/runway-imagine',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/runway-imagine");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"generation_type\": \"text2video\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/runway-imagine")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "generation_type": "text2video",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# WAN VIDEO

Generate videos using Alibaba Cloud Wan models. Supports both text-to-video and image-to-video.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/wan-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>string</td><td>Text description of the desired video. Max 1500 characters. Required for <code>wan2.6-flash</code>, optional otherwise</td></tr><tr><td><code>model</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>One of: <code>wan2.5</code>, <code>wan2.6</code>, <code>wan2.6-flash</code></td></tr><tr><td><code>negative_prompt</code></td><td>string</td><td>Content to exclude from the video. Max 500 characters.</td></tr><tr><td><code>image_url</code></td><td>string</td><td><p>URL of the first-frame image. Providing this switches to image-to-video mode. Supported formats: JPEG, PNG, BMP, WEBP. Max 10 MB.</p><p><br>Required for <code>wan2.6-flash</code>, optional otherwise</p></td></tr><tr><td><code>audio_url</code></td><td>boolean</td><td>URL of an audio file to synchronize with the video. Supported formats: WAV, MP3. Duration: 3-30 seconds. Max 15 MB.</td></tr><tr><td><code>resolution</code></td><td>string</td><td><code>480P</code>, <code>720P</code>, or <code>1080P</code>. Availability depends on model (see table below). 480P for Wan2.5 only</td></tr><tr><td><code>duration</code></td><td>integer</td><td>Video duration in seconds. Range depends on model.<br>2-15 for Any 2.6 model and 5 or 10 for Wan2.5.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "wan-video",
    "video_url": "https://...........xxxx.mp4", // 
    "status": "finished",
    "percentage": 100
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "wan-video",
    "status": "processing",
    "percentage": "40",
}
```

Credit cost:

| Model               | Resolution | Credits/sec |
| ------------------- | ---------- | ----------- |
| `wan2.5` / `wan2.6` | 1080P      | 11          |
| `wan2.5` / `wan2.6` | 720P       | 8           |
| `wan2.5`            | 480P       | 4           |
| `wan2.6-flash`      | 1080P      | 6           |
| `wan2.6-flash`      | 720P       | 4           |


# Seedance

Generate videos using ByteDance's Seedance models. Supports text-to-video and image-to-video generation.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/seedance-imagine`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>string</td><td>Text description for the video (3-2500 characters)</td></tr><tr><td><code>model</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>One of: <code>seedance-1.5-pro</code>, <code>seedance-2</code>, or <code>seedance-2-fast</code></td></tr><tr><td><code>image_url</code></td><td>string</td><td>Image URL for image-to-video (seedance-1.5-pro only)</td></tr><tr><td><code>first_frame_url</code></td><td>string</td><td>First frame image URL for I2V (seedance-2 / seedance-2-fast only)</td></tr><tr><td><code>last_frame_url</code></td><td>boolean</td><td>Last frame image URL for I2V (seedance-2 / seedance-2-fast only)</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td><code>1:1</code>, <code>4:3</code>, <code>3:4</code>, <code>16:9</code> (default), <code>9:16</code>, <code>21:9</code>. Also <code>adaptive</code> for seedance-2/seedance-2-fast.</td></tr><tr><td><code>resolution</code></td><td>string</td><td><code>480p</code>, <code>720p</code> (default), or <code>1080p</code> (seedance-1.5-pro only)</td></tr><tr><td><code>duration</code></td><td>integer</td><td><code>4</code>, <code>8</code> (default), or <code>12</code> seconds</td></tr><tr><td><code>generate_audio</code></td><td>string</td><td>Generate audio for the video (default: false). Doubles the credit cost.</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "seedance-video",
    "video_url": "https://...........xxxx.mp4", // 
    "status": "finished",
    "percentage": 100
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "seedancee-video",
    "status": "processing",
    "percentage": "40",
}
```

Credit cost:

| Model            | 480p 4s | 480p 8s | 480p 12s | 720p 4s | 720p 8s | 720p 12s | 1080p 4s | 1080p 8s | 1080p 12s |
| ---------------- | ------- | ------- | -------- | ------- | ------- | -------- | -------- | -------- | --------- |
| seedance-1.5-pro | 4       | 8       | 12       | 8       | 16      | 24       | 16       | 32       | 48        |
| seedance-2       | 28      | 56      | 84       | 60      | 120     | 180      | —        | —        | —         |
| seedance-2-fast  | 24      | 48      | 72       | 52      | 104     | 156      | —        | —        | —         |

With `generate_audio: true`, all costs are doubled.


# KLING AI API

Generate realistic videos with Kling AI


# KLING 2.6

Generate cinematic videos with synchronized audio using Kling 2.6 Pro. Supports both text-to-video and image-to-video generation.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/kling-imagine-2-6`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Text prompt for video generation (max 2000 characters)</td></tr><tr><td><code>negative_prompt</code></td><td>string</td><td>Things you do not want to see in the video (max 2000 characters)</td></tr><tr><td><code>image_url</code></td><td>string</td><td>First frame image URL for image-to-video generation</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Video aspect ratio. Options: 16:9, 9:16, 1:1. Ignored if image_url is provided.</td></tr><tr><td><code>duration</code></td><td>integer</td><td>Video duration in seconds. Options: 5 or 10. Default: 5</td></tr><tr><td><code>generate_audio</code></td><td>boolean</td><td>Generate synchronized audio (speech, ambient sounds, effects). Default: false</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "kling-2.6-video",
    "video_url": "https://...........xxxx.mp4", // 
    "status": "finished",
    "percentage": 100
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "kling-2.6-video",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/kling-2.6-video',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/kling-2.6-video"

payload = json.dumps({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/kling-2.6-video',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/kling-2.6-video")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/kling-2.6-video',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/kling-2.6-video");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n    \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/kling-2.6-video")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# KLING 2.5 TURBO PRO

Generate cinematic videos with smooth motion and remarkable prompt adherence using Kling 2.5 Turbo Pro. Supports text-to-video and image-to-video with start/end frame control.

<mark style="color:green;">`POST`</mark> `https://api.apiframe.pro/kling-imagine-2-5-turbo-pro`

**Headers**

| Name                                            | Value                 |
| ----------------------------------------------- | --------------------- |
| Content-Type                                    | `application/json`    |
| Authorization<mark style="color:red;">\*</mark> | Your APIFRAME API Key |

**Body**

<table><thead><tr><th width="200">Name</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>prompt</code><mark style="color:red;"><code>*</code></mark></td><td>string</td><td>Text prompt for video generation (max 2000 characters)</td></tr><tr><td><code>negative_prompt</code></td><td>string</td><td>Things you do not want to see in the video (max 2000 characters)</td></tr><tr><td><code>start_image</code></td><td>string</td><td>First frame image URL for image-to-video generation</td></tr><tr><td><code>end_image</code></td><td>string</td><td>Last frame image URL for image-to-video generation</td></tr><tr><td><code>aspect_ratio</code></td><td>string</td><td>Video aspect ratio. Options: 16:9, 9:16, 1:1. Ignored if image_url is provided.</td></tr><tr><td><code>duration</code></td><td>integer</td><td>Video duration in seconds. Options: 5 or 10. Default: 5</td></tr><tr><td><code>webhook_url</code></td><td>string</td><td>The final result and updates of this task will be posted at this URL.</td></tr><tr><td><code>webhook_secret</code></td><td>string</td><td>Will be passed as <code>x-webhook-secret</code> in the webhook call headers for authentication.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
// Success, the task has been submitted
{
  "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a"
}
```

{% endtab %}

{% tab title="400" %}

```json
// Bad request
{
  "errors": [{ msg: "Invalid request" }]
}
```

{% endtab %}

{% tab title="401" %}

```json
// Invalid API Key
{}
```

{% endtab %}

{% tab title="500" %}

```json
// A server error occured
{}
```

{% endtab %}
{% endtabs %}

This endpoint doesn't generate the video instantly, you can use the [Fetch](/api-endpoints/fetch) endpoint to fetch the result or use [webhooks](/webhooks).

The result (posted to the `webhook_url` or retrieved with the [Fetch](/api-endpoints/fetch) endpoint) looks like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "kling-2.5-turbo-pro-video",
    "video_url": "https://...........xxxx.mp4", // 
    "status": "finished",
    "percentage": 100
}
```

If the job is not completed, you will get a result like this:

```json
{
    "task_id": "29e983ca-7e86-4017-a9e3-ef6fe9cd5f2a",
    "task_type": "kling-2.5-turbo-pro-video",
    "status": "processing",
    "percentage": "40",
}
```

Code samples

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});

const config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.apiframe.pro/kling-imagine-2-5-turbo-pro',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.apiframe.pro/kling-imagine-2-5-turbo-pro"

payload = json.dumps({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.apiframe.pro/kling-imagine-2-5-turbo-pro',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
    "webhook_url": "https://........",
    "webhook_secret": "abc123"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n     \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.apiframe.pro/kling-imagine-2-5-turbo-pro")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Flutter" %}

```dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'YOUR_API_KEY'
};
var data = json.encode({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
});
var dio = Dio();
var response = await dio.request(
  'https://api.apiframe.pro/kling-imagine-2-5-turbo-pro',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/kling-imagine-2-5-turbo-pro");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new StringContent("{\r\n    \"prompt\": \"A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.\",\r\n   \"webhook_url\": \"https://........\",\r\n    \"webhook_secret\": \"abc123\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.apiframe.pro/kling-imagine-2-5-turbo-pro")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "YOUR_API_KEY"
request.body = JSON.dump({
  "prompt": "A colossal mech suit towering over a futuristic cityscape, its powerful weapons primed for battle against an unseen threat.",
  "webhook_url": "https://........",
  "webhook_secret": "abc123"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


# SORA AI API

(Coming Soon)


# Webhooks

The recommended way to receive updates about your tasks is to use Webhooks.

Status updates and final results will be sent to the `webhook_url` you set in the request. You can use the `webhook_secret`  parameter to ensure that the updates are actually coming from us; it will be passed as `x-webhook-secret` in the webhook call headers for authentication.


# MJ Banned Words

List of  words banned by Midjourney.

This list is not exhaustive and may not be 100% accurate since Midjourney didn't reveal their banned words, this list was created through user experience.\
\
Using any of this word in your prompt will prevent the task from being processed.

```
blood
twerk
making love
voluptuous
naughty
wincest
orgy
no clothes
au naturel
no shirt
decapitate
bare
nude
barely dressed
nude
bra
risque
scantily clad
cleavage
stripped
infested
full frontal
unclothed
invisible clothes
wearing nothing
lingerie
with no shirt
naked
without clothes on
negligee
zero clothes
gruesome
fascist
nazi
prophet mohammed
slave
coon
honkey
cocaine
heroin
meth
crack
kill
belle delphine
hitler
jinping
lolita
president xi
torture
disturbing
farts
fart
poop
infected
warts
shit
brown pudding
bunghole
vomit
voluptuous
seductive
sperm
sexy
sadist
sensored
censored
silenced
deepfake
inappropriate
waifu
succubus
slaughter
surgery
reproduce
crucified
seductively
explicit
inappropriate
large bust
explicit
wang
inappropriate
teratoma
intimate
see through
tryphophobia
bloodbath
wound
cronenberg
khorne
cannibal
cannibalism
visceral
guts
bloodshot
gory
killing
crucifixion
surgery
vivisection
massacre
hemoglobin
suicide
arse
labia
ass
mammaries
badonkers
bloody
minge
big ass
mommy milker
booba
nipple
oppai
booty
organs
bosom
ovaries
flesh
breasts
penis
busty
phallus
clunge
sexy female
crotch
skimpy
dick
thick
bruises
girth
titty
honkers
vagina
hooters
veiny
knob
ahegao
pinup
ballgag
car crash
playboy
bimbo
pleasure
bodily fluids
pleasures
boudoir
rule34
brothel
seducing
dominatrix
corpse
seductive
erotic
seductive
fuck
sensual
hardcore
sexy
hentai
shag
horny
crucified
shibari
incest
smut
jav
succubus
jerk off king at pic
thot
kinbaku
legs spread
sensuality
belly button
porn
patriotic
bleed
excrement
petite
seduction
mccurry
provocative
sultry
erected
camisole
tight white
arrest
see-through
feces
anus
revealing clothing
vein
loli
-edge
boobs
-backed
tied up
zedong
bathing
jail
reticulum
rear end
sakimichan
behind bars
shirtless
sakimichan
seductive
sexi
sexualiz
sexual
```


# Help Me With Integration

Do you need help integrating [ApiFrame](https://apiframe.pro/) into your application? We can help with that, reach us [here](https://chatting.page/4kfl67eg5gmwmuenx91bowbjp4dt0wq8).


# FAQ

You can find here the answers to many of your questions.

<details>

<summary>How many images can I generate simultaneously?</summary>

You can have up to 50 concurrent generations, that's 50 \* 4 = 200 images simultaneously

</details>

<details>

<summary>How many credits does a generation costs?</summary>

You can see the detailed cost of every action on the [Image credits](/my-account/image-credits) page [here](/my-account/image-credits)

</details>

<details>

<summary>I need invoices for my payments.</summary>

You can find the invoices for all your payments on the [Billing page](https://app.apiframe.pro/billing).

</details>


