Search VisionStory documentation

No documentation matched “”.

Try a feature or resource name such as , , or .

VisionStoryDevelopers

Guide

Talking Avatar Video API Quickstart

Generate and download your first AI talking avatar video with the VisionStory REST API or Python SDK, including authentication, polling, and storage.

This quickstart takes you from an API key to a saved talking-avatar MP4 in five steps: verify authentication and credits, discover a public avatar and voice, submit a text script, poll the asynchronous job, and download the result.

Before you start

API access

API keys are available on Pro plans and above. Create a key on the API keys page, then use the authentication guide to configure your backend. Keep the key server-side. API access uses your VisionStory account and generation credits.

Credits and billing

Check your current balance with the credits endpoint before submitting a generation. Talking-avatar video costs depend on the model, resolution, and duration; the video status response reports the task's cost_credit.

For prompt- or image-based AI video clips, use the separate AI video cost endpoint with the selected model and inputs. Speech synthesis reports usage and credits in its response headers. These interfaces expose costs differently; use the documentation for the workflow you are integrating.

Limits and formats

Use model discovery for supported aspect ratios, resolutions, and maximum duration. Check avatar creation for portrait requirements and the video request schema for accepted audio inputs. The AI Video guide covers the distinct limits of prompt- and reference-based video models.

1. Create a VisionStory API key

Sign up and create an API key on the VisionStory API keys page. Send it with every request in the X-API-Key header:

Request header
X-API-Key: $VISIONSTORY_API_KEY

Keep the key on your server and never expose it in browser code or a public repository. The examples below read it from an environment variable:

Shell
export VISIONSTORY_API_KEY="sk-vs-xxxxxxxxxxxxxxxxxxx"

VisionStory CLI users can instead run visionstory login after installation. It hides the input, verifies the key, and saves it for future CLI sessions without putting the secret in shell history.

Before starting a paid generation, verify the key with a read-only request:

Shell
curl -s -H "X-API-Key: $VISIONSTORY_API_KEY" \
  https://openapi.visionstory.ai/api/v1/billing/credits

A successful response includes data.remaining, your current VisionStory credit balance. A 401 response means the key is missing, expired, or no longer valid; create or replace it at API keys page before continuing.

2. Choose a client and discover resources

Choose a client for your environment, then use read-only discovery to get valid resource IDs before submitting a generation.

Python SDK

Follow the Python SDK installation and authentication guide, then use the complete SDK example below. The SDK has no runtime dependencies.

VisionStory CLI

For terminal commands, shell scripts, or CI jobs, follow the CLI guide for installation, login, and resource discovery.

AI agents

Use the Agent setup guide to install the focused talking-avatar Skill or connect the MCP server. Complete its read-only connection checks before requesting a video.

REST API

The steps below use curl; any backend HTTP client can send the same requests. See the API reference for exact request and response schemas.

Discover valid IDs with read-only requests

Query the current talking-avatar models, public avatars, and English voices. These requests do not generate media:

Shell
curl -s -H "X-API-Key: $VISIONSTORY_API_KEY" \
  https://openapi.visionstory.ai/api/v1/models

curl -s -H "X-API-Key: $VISIONSTORY_API_KEY" \
  "https://openapi.visionstory.ai/api/v1/avatars?is_public=true&limit=20"

curl -s -H "X-API-Key: $VISIONSTORY_API_KEY" \
  "https://openapi.visionstory.ai/api/v1/voices?locale=en&limit=20"

Choose an avatar_id from data.avatars and a voice_id from data.public_voices. Confirm that data.models includes vs_character_v4 with 9:16 and 720p support for the example below. If you need more avatar or voice choices, pass the returned next_cursor as cursor until it is 0; change locale to find voices for another language.

Replace YOUR_AVATAR_ID and YOUR_VOICE_ID below with your selections. They are placeholders, not usable resource IDs. Generation requires sufficient credits and account access to the selected model and voice; a positive balance alone does not guarantee the request can run.

3. Generate a talking avatar video

Submit a text script with the public avatar and voice you selected. Replace YOUR_UNIQUE_REQUEST_ID with an ID for this job and keep it for retries: within 24 hours, reusing the same client_request_id returns the original task without a second charge. The request returns a video_id immediately while generation continues asynchronously:

Shell
curl -s \
  -H "X-API-Key: $VISIONSTORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": "vs_character_v4",
    "avatar_id": "YOUR_AVATAR_ID",
    "client_request_id": "YOUR_UNIQUE_REQUEST_ID",
    "text_script": {
      "text": "Hello World, this is my first test video.",
      "voice_id": "YOUR_VOICE_ID",
      "speech_rate": "normal"
    },
    "aspect_ratio": "9:16",
    "resolution": "720p"
  }' \
  https://openapi.visionstory.ai/api/v1/video
JSON
{
  "data": {
    "video_id": "YOUR_VIDEO_ID"
  }
}

To use your own audio, send an audio_script in place of text_script — never both.

4. Poll the video generation job

Replace YOUR_VIDEO_ID with the returned data.video_id, then query the task every 5 seconds until it reaches a final state:

Shell
curl -s \
  -H "X-API-Key: $VISIONSTORY_API_KEY" \
  "https://openapi.visionstory.ai/api/v1/video?video_id=YOUR_VIDEO_ID"
statusMeaning
queuedAccepted, waiting for a worker
creatingGenerating
createdDone — video_url is ready
failedGeneration failed — stop polling and inspect the error

Avoid polling faster than every 5 seconds, and give up after about 10 minutes.

5. Download the generated MP4

When the status is created, the response carries a video_url. Completed videos are retained for 7 days, so download the file if you need permanent storage:

Shell
curl -sL -o result.mp4 "<video_url from the response>"

Complete Python SDK example

After installing the SDK and setting VISIONSTORY_API_KEY, this example checks credits and discovers resources before submitting a paid generation. It selects the first returned public avatar and English voice. The SDK unwraps the REST data envelope, so read avatars and public_voices directly from its responses:

Python
from pathlib import Path
from uuid import uuid4
from visionstory import VisionStoryClient, build_video_payload

client = VisionStoryClient.from_env()
credits = client.get_credits()
if credits["remaining"] <= 0:
    raise RuntimeError("Add credits before generating a video.")

models = client.list_models()["models"]
model = next((item for item in models if item["model_id"] == "vs_character_v4"), None)
avatars = client.list_avatars(is_public=True, limit=1)["avatars"]
voices = client.list_voices(locale="en", limit=1)["public_voices"]
if model is None or not avatars or not voices:
    raise RuntimeError("No matching resources. Review model, avatar, and voice discovery.")
if "9:16" not in model.get("aspect_ratios", []) or "720p" not in model.get("resolutions", []):
    raise RuntimeError("Choose an aspect ratio and resolution supported by the model.")

payload = build_video_payload(
    model_id=model["model_id"],
    avatar_id=avatars[0]["avatar_id"],
    text="Hello World, this is my first test video.",
    voice_id=voices[0]["voice_id"],
    aspect_ratio="9:16",
    resolution="720p",
)
payload["client_request_id"] = uuid4().hex  # Keep this value for retries of this job.
print("client_request_id:", payload["client_request_id"])
video = client.generate_video(payload, poll_interval=5, timeout=600)
client.download(video["video_url"], Path("result.mp4"))
print("saved result.mp4")

generate_video() submits and polls, raises an error on failed, and stops waiting after 600 seconds. A timeout does not cancel the server job. Keep the printed client_request_id for a retry of the same submission; rerunning the whole example creates a new ID and can create another charged job. Download successful results within the 7-day storage window.