---
title: Hailuo Testo in video | RunAPI
description: Usa l'endpoint da testo a video per creare un Task asincrono.
url: https://runapi.ai/it/docs/api/hailuo/text-to-video.md
canonical: https://runapi.ai/it/docs/api/hailuo/text-to-video
locale: it
---

> Versione HTML: https://runapi.ai/it/docs/api/hailuo/text-to-video
> Indice del sito per gli agenti: https://runapi.ai/llms.txt

# Hailuo Testo in video

## Panoramica

Usa l'endpoint da testo a video con un modello supportato. Utilizza il Task ID restituito per recuperarne lo stato, oppure fornisci callback_url per le consegne documentate di seguito.

### Avvio rapido

1. Crea una Chiave API e impostala come RUNAPI_API_KEY.
2. Scegli un modello supportato e invia una richiesta POST il cui corpo corrisponda allo schema di quel modello.
3. Conserva l'ID attività restituito, quindi esegui il polling fino a uno stato terminale o gestisci i callback documentati di seguito.

## Endpoint

POST /api/v1/hailuo/text_to_video

URL di base: https://runapi.ai

Versione API: v1

Autenticazione: Authorization: Bearer YOUR_API_TOKEN

## Modelli supportati

Apri la pagina di un modello per i prezzi correnti, i limiti di frequenza e i dettagli sull'uso commerciale.

- [hailuo-02-text-to-video-pro](https://runapi.ai/it/models/hailuo/02-text-to-video-pro)
- [hailuo-02-text-to-video-standard](https://runapi.ai/it/models/hailuo/02-text-to-video-standard)

## Schema della richiesta

I campi e i valori consentiti dipendono dal modello selezionato. Se fornito, callback_url riceve le notifiche Task documentate di seguito.

### hailuo-02-text-to-video-pro

```json
{
  "callback_url": {
    "type": "string"
  },
  "duration_seconds": {
    "type": "integer"
  },
  "enable_safety_checker": {
    "type": "boolean"
  },
  "model": {
    "type": "string"
  },
  "prompt": {
    "type": "string"
  },
  "prompt_optimizer": {
    "type": "boolean"
  }
}
```

### hailuo-02-text-to-video-standard

```json
{
  "callback_url": {
    "type": "string"
  },
  "duration_seconds": {
    "enum": [
      6,
      10
    ],
    "type": "integer"
  },
  "enable_safety_checker": {
    "type": "boolean"
  },
  "model": {
    "type": "string"
  },
  "prompt": {
    "type": "string"
  },
  "prompt_optimizer": {
    "type": "boolean"
  }
}
```

## Crea accettazione

HTTP 202 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    },
    "task_replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## Polling in elaborazione

HTTP 200 - GET /api/v1/hailuo/text_to_video/:id

### Schema della risposta

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## Polling completato

HTTP 200 - GET /api/v1/hailuo/text_to_video/:id

### Schema della risposta

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
```

## Polling non riuscito

HTTP 200 - GET /api/v1/hailuo/text_to_video/:id

### Schema della risposta

```json
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "error": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "error": "Task processing failed.",
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## Callback cliente: completato

HTTP 200 - POST callback_url

### Schema della risposta

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
```

## Callback cliente: fallito

HTTP 200 - POST callback_url

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "properties": {
            "code": {
              "type": "string"
            },
            "limit_cents": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            },
            "reset_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "used_cents": {
              "type": "integer"
            },
            "window": {
              "enum": [
                "1h",
                "1d",
                "7d",
                "daily",
                "weekly",
                "monthly",
                "lifetime"
              ],
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object",
          "unevaluatedProperties": false
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": {
    "code": "generation_failed",
    "message": "Task processing failed."
  },
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## Errori

HTTP 401 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Authentication required"
}
```

## Errori

HTTP 401 - GET /api/v1/hailuo/text_to_video/:id

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Authentication required"
}
```

## Errori

HTTP 400 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Messaggio di errore leggibile.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Riepilogo di convalida leggibile dall'utente.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### Esempio di risposta

```json
{
  "error": "model must be one of: hailuo-02-text-to-video-pro, hailuo-02-text-to-video-standard"
}
```

## Errori

HTTP 402 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Insufficient balance"
}
```

## Errori

HTTP 429 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "API key credit limit exceeded"
}
```

## Errori

HTTP 409 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "The request uses features that are not supported for the selected model"
}
```

## Errori

HTTP 429 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Rate limit reached. Please retry later."
}
```

## Errori

HTTP 503 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Service under maintenance, please try again later"
}
```

## Errori

HTTP 504 - POST /api/v1/hailuo/text_to_video

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "The request timed out"
}
```

## Errori

HTTP 404 - GET /api/v1/hailuo/text_to_video/:id

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Task with id 'tsk_reference_demo' not found"
}
```

## Esempi di Codice Generati

Usa cURL direttamente, oppure installa un SDK per il tuo linguaggio. Ogni esempio invia la richiesta validata mostrata in questo riferimento.

### curl

```curl
curl -X POST https://runapi.ai/api/v1/hailuo/text_to_video \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"hailuo-02-text-to-video-pro","prompt":"A slow aerial view of a quiet coastline at sunrise."}'
```

### javascript

#### Installa

```bash
npm install @runapi.ai/hailuo
```

```javascript
import { HailuoClient } from "@runapi.ai/hailuo";

const client = new HailuoClient({ apiKey: process.env.RUNAPI_API_KEY });
const task = await client.textToVideo.create({
  "model": "hailuo-02-text-to-video-pro",
  "prompt": "A slow aerial view of a quiet coastline at sunrise."
});
```

### python

#### Installa

```bash
pip install runapi-hailuo
```

```python
import os
from runapi.hailuo import HailuoClient

client = HailuoClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
  model="hailuo-02-text-to-video-pro",
  prompt="A slow aerial view of a quiet coastline at sunrise."
)
```

### go

#### Installa

```bash
go get github.com/runapi-ai/hailuo-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  hailuo "github.com/runapi-ai/hailuo-sdk/go/hailuo"
)

func main() {
  client, err := hailuo.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
  if err != nil {
    log.Fatal(err)
  }

  task, err := client.TextToVideo.Create(context.Background(), hailuo.TextToVideoParams{
    Model: hailuo.TextToVideoModel("hailuo-02-text-to-video-pro"),
    Prompt: "A slow aerial view of a quiet coastline at sunrise.",
  })
  if err != nil {
    log.Fatal(err)
  }
  _ = task
}
```

### ruby

#### Installa

```bash
gem install runapi-hailuo
```

```ruby
require "runapi/hailuo"

client = RunApi::Hailuo::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
task = client.text_to_video.create(
  model: "hailuo-02-text-to-video-pro",
  prompt: "A slow aerial view of a quiet coastline at sunrise."
)
```

### java

#### Installa

```kotlin
implementation("ai.runapi:runapi-hailuo")
```

```java
import ai.runapi.hailuo.HailuoClient;
import ai.runapi.hailuo.types.TextToVideoParams;
import ai.runapi.core.polling.TaskCreateResponse;

public final class Example {
  public static void main(String[] args) {
    HailuoClient client = HailuoClient.builder()
        .apiKey(System.getenv("RUNAPI_API_KEY"))
        .build();
    TaskCreateResponse task = client.textToVideo().create(
        TextToVideoParams.builder()
        .model("hailuo-02-text-to-video-pro")
        .prompt("A slow aerial view of a quiet coastline at sunrise.")
            .build()
    );
  }
}
```

### php

#### Installa

```bash
composer require runapi-ai/hailuo
```

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use RunApi\Core\ClientOptions;
use RunApi\Hailuo\HailuoClient;

$client = new HailuoClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$task = $client->textToVideo->create([
  "model" => "hailuo-02-text-to-video-pro",
  "prompt" => "A slow aerial view of a quiet coastline at sunrise."
]);
```

## Guide correlate

- [Autenticazione](https://runapi.ai/it/docs/guides/authentication.md)
- [Guida introduttiva](https://runapi.ai/it/docs/guides/task-api/quickstart.md)

---

## Altre risorse di RunAPI

- [Home](https://runapi.ai/it/.md)
- [Catalogo dei modelli](https://runapi.ai/it/models.md)
- [Prezzi](https://runapi.ai/it/pricing.md)
- [Fornitori](https://runapi.ai/it/models)
- [Documentazione](https://runapi.ai/it/docs/guides)
- [SDK](https://runapi.ai/it/sdk.md)
- [CLI](https://runapi.ai/it/cli.md)
- [MCP Server](https://runapi.ai/it/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/it/claude-code-vs-cursor.md)
- [Configurazione Cursor API](https://runapi.ai/it/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/it/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/it/contact.md)
- [Contatti](https://runapi.ai/it/contact.md)
- [Termini](https://runapi.ai/it/terms.md)
- [Privacy](https://runapi.ai/it/privacy.md)
- [Indice del sito per gli agenti](https://runapi.ai/llms.txt)

Contatti: contact@runapi.ai

## Dati strutturati

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/it/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/iticon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "TechArticle",
    "headline": "Hailuo Testo in video",
    "description": "Usa l'endpoint da testo a video per creare un Task asincrono.",
    "url": "https://runapi.ai/it/docs/api/hailuo/text-to-video",
    "mainEntityOfPage": "https://runapi.ai/it/docs/api/hailuo/text-to-video"
  }
]
```
