Skip to content

About

Python quickstart for ToAPIs chat, image, and video APIs, with async task polling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ToAPIs Quickstart: text, image, and video in Python

Model support and prices · 2026-10-20

Added standalone API presets: 31 image request templates and 8 video presets. Current-key pricing matches 26 image and 8 video presets; 5 image templates block new paid calls while pricing is unavailable. Native provider/UI/import/render acceptance remains as documented in the original guide below.

Image model / tested preset Current preset quote / image Historical example amount / image Fee evidence
gpt-image-2(VIP)
low
$0.0019/image $0.0019/image Billing log, phase unknown
gpt-image-2.5-flare-vip
low
Current-key quote unavailable $0.005272/image
Token-metered; current $/M unavailable. This sample is not a fixed image tariff.
Task receipt settled
nano_banana
1K
$0.012/image $0.012/image Billing log, phase unknown
gemini-nano-banana-2.1
1K
$0.015/image $0.015/image Billing log, phase unknown
gpt-image-2
1K
$0.015/image $0.015/image Billing log, phase unknown
gemini-nano-banana-2.1-vip
1K
$0.02/image $0.02/image Billing log, phase unknown
qwen-image-3.0
1K
Current-key quote unavailable $0.021/image Billing log, phase unknown
gpt-image-2.5-flare
high
$0.0225/image $0.0225/image Billing log, phase unknown
gpt-image-2.5-sunburst
high
$0.0225/image $0.0225/image Billing log, phase unknown
flux-2-pro
1K
$0.025/image $0.025/image Billing log, phase unknown
doubao-seedream-5-0-pro
1K
$0.042857/image $0.042856/image Billing log, phase unknown
Video model Preset / input Settled clip charge File duration Case USD/s, ascending
MiniMax-H3-Max-Turbo 5s / 480P / text-to-video $0.125/clip 5.18s $0.024131/s
Pricing tariff: $0.025/s
seedance-2-mini 4s / 480p / first-frame $0.13338/clip 4.04s $0.033015/s
Pricing tariff: $3.285714/M total tokens
seedance-2-fast 4s / 480p / text-to-video $0.214568/clip 4.04s $0.053111/s
Pricing tariff: $5.285714/M total tokens
kling-v3 5s / 720p / std / text-to-video $0.3/clip 5.04s $0.059524/s
Pricing tariff: $0.06/s
MiniMax-H3 5s / 768p / text-to-video $0.32/clip 5.17s $0.061896/s
Pricing tariff: $0.064/s
seedance-2 4s / 480p / first-frame $0.26676/clip 4.04s $0.06603/s
Pricing tariff: $6.571429/M total tokens
kling-3.0-turbo 4s / 720p / text-to-video $0.32/clip 4.04s $0.079208/s
Pricing tariff: $0.08/s
seedance-2-5 4s / 480p / text-to-video $0.3883/clip 4.04s $0.096114/s
Pricing tariff: $10/M total tokens

Pricing checked 2026-10-20. Image examples are dated 2026-10-17; video examples 2026-10-20. Tables sort by example amount or case USD/s. Presets and input modes differ; this is not a matched-settings quality ranking. Unknown-phase image logs are not confirmed final net settlements. Current quotes and historical amounts are separate. Video charges are billing=settled; case USD/s divides charge by actual file duration, never processing time. Token tariffs appear in small text and do not imply a fixed per-second price.

gpt-image-2(VIP) starts at $0.0019/image; this low/1K preset is $0.0019/image. The standalone sampler has 31 historically successful image request templates and 8 video presets. Current-key pricing matches 26 image and 8 video presets; 5 image templates block new paid submission until an exact price is available.

Local sampler · Full price table · Original media and fee evidence

Original project examples, historical charges and integration instructions follow. Historical amounts are not rewritten as today’s quotes.

ToAPIs logo

One Python script, three API workflows. Call a chat model, create an image, or submit a video generation task through ToAPIs. No third-party Python packages are required.

Built for developers connecting models to applications and recurring workflows. Start with one verified request, inspect actual usage, then plan your production integration. High-volume integration enquiries should include your models, estimated monthly usage, peak concurrency, and launch timeline.

English · 简体中文

Start with --dry-run: it shows the endpoint and request body without an API key or billable call. Live calls require a key and may incur charges. Model availability and prices can change; check the current pricing page.

Project image tutorials

Tested on Oct 12: MeiGen local MCP with a community patch and TongFlow plugin image-gen CLI. Each guide includes a real PNG, pinned version, reproduction steps and dated pricing.

What this example covers

Workflow Model used in this example API behavior
Text gpt-6.1-sol Synchronous chat completion
Image gpt-image-2-vip (1K, low) Submit task, then poll for result URL
Video seedance-2 (4 s, 720p, no audio) Submit task, then poll for result URL

The script follows the official quickstart. ToAPIs also lists Suno music generation; this quickstart has no Suno example because its request and task response still need a verified API contract. It does not cover TTS.

1. Check the request without spending credits

Install Python 3.10 or newer, clone this repository, then run:

python examples/quickstart.py chat --dry-run
python examples/quickstart.py image --prompt "A paper crane on an orange background" --dry-run
python examples/quickstart.py video --prompt "A paper crane unfolds on a desk, cinematic light" --dry-run

On Windows, py may be used in place of python.

2. Get a key and make one live call

Create a ToAPIs API key in your account. Store it as an environment variable. Do not paste it into a source file or commit it to GitHub.

macOS / Linux:

export TOAPIS_API_KEY="YOUR_API_KEY"
python examples/quickstart.py chat --prompt "Explain an API gateway in one sentence."

PowerShell:

$env:TOAPIS_API_KEY = "YOUR_API_KEY"
python .\examples\quickstart.py chat --prompt "Explain an API gateway in one sentence."

For users served by the China endpoint, set TOAPIS_BASE_URL=https://toapis.cn (or pass --base-url https://toapis.cn). The script appends /v1 automatically.

3. Try image or video

python examples/quickstart.py image --prompt "A clean orange-and-black geometric poster"
python examples/quickstart.py video --prompt "A paper crane unfolds on a desk, cinematic light"

The image command defaults to gpt-image-2-vip at 1K and low quality. To try its other quality levels, add --image-quality medium or --image-quality high. To use the standard model, add --image-model gpt-image-2; that model uses its fixed medium quality, so the script omits the quality field. See the credits and billing steps below before making live calls. The video command uses seedance-2 with a 4-second duration, 720p resolution, 16:9 aspect ratio, and generate_audio=false. Review Seedance 2 parameters and pricing before making a live video call.

Image and video requests return a task ID first. The script checks its status every 8 seconds, for up to 15 minutes, and prints the result URL when complete. Generated links may expire; save output you need promptly. Use --interval and --max-wait to change polling. If your terminal times out after submission, keep the printed task ID and query the image task or video task endpoint directly.

Before sustained or batch usage

This is a single-request quickstart, not a batch runner. For production use, add bounded concurrency, persistent task IDs, result storage, and a workload budget in your application. Check account limits and model-specific parameters before increasing volume. After an interrupted generation request, inspect the existing task before resubmitting to avoid duplicate work and charges.

For integration planning, request 1:1 support with your use case, models, estimated monthly usage, peak concurrency, and launch timeline. Capacity and dedicated support scope are assessed for the project.

For API troubleshooting, send the endpoint, model, HTTP status, task/request ID, and redacted reproduction. Use repository Issues for example-code defects; contact support privately for account and billing questions. Never share API keys.

Free credits, billing, and top-ups

New accounts receive 10 credits—enough to generate 26 images with gpt-image-2-vip at 1K resolution and low quality under current pricing. Higher quality settings or other models use different amounts of credits. The 10 signup credits do not cover this repository's Seedance video example; review pricing and top up before making a live video call. Public price displays can lag updates. Check the current price list before changing models or settings. Actual credit usage is determined by your account's Usage Logs.

After a live call, copy the task ID printed by the script. Sign in to the Dashboard with the same account. Open Task Logs to find the image or video task and its result, and use Usage Logs to inspect the charge or credit usage for the request. If the entry is delayed, refresh the logs and compare the account balance after it appears. The amount recorded in the account is the final charge.

When the free credits are used, open Billing / Top up in the Dashboard to review available recharge options. Review the amount and payment details there before paying.

API routes used

POST /v1/chat/completions
POST /v1/images/generations
GET  /v1/images/generations/{task_id}
POST /v1/videos/generations
GET  /v1/videos/generations/{task_id}

The default base is https://toapis.com. See the API documentation for parameters, response formats, and other models. Browse the model catalog before changing the model IDs in the script.

Troubleshooting

Symptom First check
TOAPIS_API_KEY error Set the variable in the same terminal session.
HTTP 401 Check that the key is active and copied correctly.
HTTP 400 Check model availability and request parameters in the current docs.
HTTP 429 Check your account limits and retry later.
Task times out Use the printed task ID to inspect status; video can take longer than the default wait.

Verify and contribute

python -m unittest discover -s tests

The automated tests check request shapes and do not make paid calls. Manual live smoke checks completed on 2026-10-09 for the default chat, image, and video workflows. Issues and pull requests that keep the examples aligned with the official docs are welcome.

Documentation checked: 2026-10-09. License: MIT.

Image and video asset examples

Browse 10 real API asset tutorials and cost notes

Image/video model cost index

Browse model types and example costs for 25 tutorials

Image model costs and outputs (2026-10-17)

8 models, one prompt: outputs ordered by example amount. gpt-image-2(VIP) low/1K is $0.0019/image. Cost evidence and project validation scope are stated separately.

About

Python quickstart for ToAPIs chat, image, and video APIs, with async task polling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages