Contact ustokvi@gmail.com

TOKVI GLOBAL / DEVELOPER DOCS

Bring AI models into your product.

Connect to models from China and around the world through Tokvi Global. This guide uses https://tokvi.ai and covers API key authentication, text, image generation and editing, Wan video tasks and MiniMax-H3.

Quick start

  1. Create a Tokvi Global account and verify your email, or sign in to your existing global account.
  2. Create a key on the console’s API keys page. Check its selected group, model permissions, spending limit and expiration date.
  3. Set the TOKVI_API_KEY environment variable on your server and use the examples below to call a model.
  4. Review request results and charges in your usage logs.

Accounts, API keys, balances and usage logs are separate between the global and China sites. Global account balances and model prices are displayed in USD. Do not use keys or endpoints from the China site here.

For OpenAI-compatible clients that require a Base URL, enter https://tokvi.ai/v1. When using curl directly, use the full endpoint URL and avoid adding /v1 twice.

Client setup reference

The following configurations are provided as setup references for WorkBuddy, OpenCode, Claude Code and Codex. Fields and setup methods may vary by client version; follow the interface and official documentation for your installed version. Replace the example API Key and model ID with your own details, and choose the address for the site where your key was issued.

Copy the API Key itself from the console, not the connection JSON. Replace YOUR_MODEL_ID with an exact model ID available to your key on this site.

Choose the correct address

UseAddress
OpenAI Base URL: WorkBuddy / OpenCode / Codexhttps://tokvi.ai/v1
Full Chat Completions endpoint: direct HTTPhttps://tokvi.ai/v1/chat/completions
Claude Code / Anthropic Base URLhttps://tokvi.ai
https://tokvi.ai/v1

Base URL is the API prefix, not the full endpoint. Avoid /v1/v1 and repeated /chat/completions. If a client automatically appends /v1, follow that version’s URL rules and use the site root. The console connection JSON now contains a /v1 URL; this project removes that suffix when importing a channel. Older external channel importers may require the site root entered manually.

WorkBuddy

  1. Open Settings → Models → Add model → Custom.
  2. Set Base URL to https://tokvi.ai/v1 and enter your API Key and model ID separately.
  3. Keep Custom protocol off for standard URL completion. If you turn it on, enter the full endpoint https://tokvi.ai/v1/chat/completions.
  4. Save and select the new Tokvi model in the conversation model picker; Auto does not guarantee this model is selected.

For agent tasks such as reading files or running commands, enable Tool calling in the custom model’s capability settings if the selected model supports it. A custom provider may leave this off by default: a successful chat or connection test does not establish agent capability. Enable image input or reasoning controls only when supported by the model and gateway.

WorkBuddy official guide

Environment variables for command-line tools

Set the variable on your own computer and start OpenCode or Codex from the same terminal. The commands below apply only to that terminal session. Keep real keys out of shared project files.

macOS / Linux:

export TOKVI_API_KEY='YOUR_API_KEY'

Windows PowerShell:

$env:TOKVI_API_KEY = 'YOUR_API_KEY'

OpenCode

Run opencode --version first. V1 and V2 use different configuration fields. Merge the matching example into the project’s opencode.json and keep other settings. Replace YOUR_MODEL_ID in both model and models.

OpenCode V2
{
  "$schema": "https://opencode.ai/config.json",
  "model": "tokvi/YOUR_MODEL_ID",
  "providers": {
    "tokvi": {
      "name": "Tokvi",
      "env": [
        "TOKVI_API_KEY"
      ],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://tokvi.ai/v1"
      },
      "models": {
        "YOUR_MODEL_ID": {
          "name": "Tokvi model"
        }
      }
    }
  }
}
OpenCode V1
{
  "$schema": "https://opencode.ai/config.json",
  "model": "tokvi/YOUR_MODEL_ID",
  "provider": {
    "tokvi": {
      "name": "Tokvi",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://tokvi.ai/v1",
        "apiKey": "{env:TOKVI_API_KEY}"
      },
      "models": {
        "YOUR_MODEL_ID": {
          "name": "Tokvi model"
        }
      }
    }
  }
}

Start opencode from the terminal with TOKVI_API_KEY set, then use /models to select tokvi/YOUR_MODEL_ID. These examples select Chat Completions. OpenCode V2 · OpenCode V1

Claude Code

Claude Code uses Anthropic Messages, with the site root as ANTHROPIC_BASE_URL. Merge this env block into your user settings at ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json). Back up existing settings and preserve other entries. Replace YOUR_API_KEY and YOUR_MODEL_ID.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://tokvi.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_MODEL": "YOUR_MODEL_ID",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "YOUR_MODEL_ID",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "YOUR_MODEL_ID",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "YOUR_MODEL_ID"
  }
}

Restart Claude Code and use /status to inspect the gateway. Model aliases above point to the selected model; explicit models in other settings can still override them. The model must support Messages and the capabilities your task needs. Official gateway guide

Codex CLI

Merge this configuration into ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml), preserving unrelated entries and replacing YOUR_MODEL_ID. Do not duplicate existing TOML keys or tables.

model = "YOUR_MODEL_ID"
model_provider = "tokvi"

[model_providers.tokvi]
name = "Tokvi"
base_url = "https://tokvi.ai/v1"
env_key = "TOKVI_API_KEY"
wire_api = "responses"
requires_openai_auth = false

Start codex from the terminal with TOKVI_API_KEY set. Current custom providers use Responses; Chat Completions availability alone does not establish Codex compatibility. This example covers the CLI; desktop and IDE settings must be checked separately. OpenAI official configuration reference

Check the result

Saving configuration is not a connection test. Model listing does not prove generation, streaming or tool calling. A connection test or message can incur usage charges. If a request fails, share the client version, time and redacted error; never share the full key.

Authentication and models

Model endpoints use API keys with Bearer authentication:

Authorization: Bearer $TOKVI_API_KEY

Keep API keys on your server. Do not expose them in public web pages, source repositories or logs. To rotate a key, create a new one in the console and disable the old key when it is no longer needed.

Choose the right group

For the image and Wan video examples below, select the image/video discount group labelled 22–25% off when creating your key, or use Auto when available. A key assigned only to the H3 group does not automatically gain access to other image or video models. Use the model IDs exactly as shown below.

List models available to your key

curl https://tokvi.ai/v1/models \
  -H "Authorization: Bearer $TOKVI_API_KEY"

Use a model ID from the returned list in your requests. The model catalog may list more models than an individual key can access.

Text models

Text models that support the OpenAI-compatible protocol can be called through POST /v1/chat/completions. This example uses qwen3.8-flash, which is listed on the global site. Confirm that your key has access and sufficient balance before calling it.

curl https://tokvi.ai/v1/chat/completions \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-flash",
    "messages": [
      {"role": "user", "content": "Hello, Tokvi"}
    ]
  }'

Text in a non-streaming response is usually returned in choices[0].message.content. For models that support streaming, set "stream": true and process the response as SSE events.

When switching to GPT, Claude, DeepSeek or another model, use its exact ID from the catalog. Check its supported endpoints, context limits, image inputs and tool parameters. Image generation and video tasks use different request formats from the text example above. For deepseek-v4.1-flash, use streaming while non-streaming compatibility is being corrected.

Image generation and editing

The following image models are enabled on the global site. They use different APIs; choose the example for your model.

ModelAPIResult
qwen-image-2.0-proPOST /v1/images/generationsImage URL in the synchronous response
wan2.7-image
wan2.7-image-pro
POST /v1/responsesBackground task; poll for completion

Qwen: text to image

This example generates one 1024 × 1024 image. Read the image URL from data[0].url in a successful response.

curl https://tokvi.ai/v1/images/generations \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "qwen-image-2.0-pro",
  "prompt": "A red ceramic cup on a wooden table, soft daylight.",
  "n": 1,
  "size": "1024x1024"
}'

Qwen: edit a reference image

Replace the example image URL with your own accessible HTTPS image. The input.messages extension supplies the reference image; prompt remains required. If using an SDK, pass this extension in its extra request body.

curl https://tokvi.ai/v1/images/generations \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "qwen-image-2.0-pro",
  "prompt": "Change the cup to blue, keep the rest unchanged.",
  "n": 1,
  "size": "1024x1024",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "image": "https://your-public-host.example/reference.png"
          },
          {
            "text": "Change the cup to blue, keep the rest unchanged."
          }
        ]
      }
    ]
  }
}'

Wan: submit a background image task

Use wan2.7-image-pro in place of wan2.7-image to select the Pro model. The size field below uses an asterisk.

curl https://tokvi.ai/v1/responses \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "wan2.7-image",
  "input": "A small green ceramic vase, still life, soft daylight.",
  "n": 1,
  "size": "1024*1024",
  "background": true
}'

Save the returned id, such as resp_xxx, and poll the same Responses API:

curl https://tokvi.ai/v1/responses/resp_xxx \
  -H "Authorization: Bearer $TOKVI_API_KEY"

Wait until status is completed. The generated image link is returned as Markdown in output[].content[].text where the content type is output_text. If the status is failed, read the error and check the task log. A Responses ID is not interchangeable with a native task ID.

Image and video models use their documented image/task endpoints. A generic Chat label in the catalog does not mean these models accept /v1/chat/completions. Returned media links may expire; retrieve your results promptly.

Wan video API

wan3.0-video and wan3.0-video-prime support asynchronous video generation. Both accept 480P, 720P and 1080P. The examples use a fixed two-second output at 480P. Generation time varies with the model and queue.

Each POST can create a new billable task. Save its ID and poll that task. Do not automatically resubmit after a timeout: first check whether the original task was created.

1. Submit text to video

curl https://tokvi.ai/v1/videos \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "wan3.0-video-prime",
  "prompt": "A quiet mountain valley at sunrise, slow clouds, still camera.",
  "seconds": 2,
  "resolution": "480P",
  "ratio": "16:9",
  "audio": false
}'

Image to video

To animate an image, submit its accessible HTTPS URL with the same API. Replace the placeholder before running this example:

curl https://tokvi.ai/v1/videos \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "wan3.0-video-prime",
  "prompt": "The camera gently moves closer to the cup.",
  "image": "https://your-public-host.example/reference.png",
  "seconds": 2,
  "resolution": "480P",
  "audio": false
}'

2. Poll the video task

Save the submission response’s id, then replace task_xxx below. Statuses include queued, in_progress, completed and failed. Wait several seconds between queries.

curl https://tokvi.ai/v1/videos/task_xxx \
  -H "Authorization: Bearer $TOKVI_API_KEY"

3. Download the completed video

When the task is completed, request its content using the same key. The status response is task metadata, not the video file.

curl https://tokvi.ai/v1/videos/task_xxx/content \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  --output tokvi-video.mp4

The content endpoint returns video bytes. Check for a successful HTTP status before using the saved MP4. For a failed task, inspect the error and task record instead of downloading content.

Wan 3.0 billing depends on resolution and the sum of billable input-video and output-video seconds. The examples above contain no reference video. Other media combinations, longer durations and audio settings have model-specific limits; check the catalog and error response before changing them.

MiniMax-H3 video generation

MiniMax-H3 uses asynchronous tasks: submit a generation request, poll its status and download the video when it is complete. You can also open the video playground if your account has playground access or visit the MiniMax-H3 API page.

Choose the mode and write the prompt

Write one non-empty prompt of up to 7,000 characters. Describe the scene, characters, actions, camera, exact dialogue and sound. This is a suggested structure, not a required language or a set of extra API fields.

For multiple voice references, explicitly identify the character and audio number: “A uses audio 1; B uses audio 2.” Numbering follows the order of items of the same media type. Use clean single-speaker clips. This is a generation instruction, not a guarantee of exact voice identity or automatic character binding; listen to the output.

Use either first/last frames or reference media; they cannot be mixed. Audio: up to 3 PCM WAV/MP3 clips, 2–15 seconds each, at most 15 seconds combined, and at most 15 MiB each (15,728,640 bytes). Video: up to 3 MP4/MOV clips, 2–15 seconds each, at most 15 seconds combined; video and audio totals are independent. Reference images: up to 9. The webpage may use stricter file-format or size limits shown beside its uploader.

API settings before sending a request

This page uses https://tokvi.ai. Use a key issued by this site, with sufficient balance and access to a group serving MiniMax-H3. A model shown in the catalog does not imply your key can call it. Put your key in Authorization: Bearer $TOKVI_API_KEY and send Content-Type: application/json.

Native format: content contains one text item and the optional media; duration is an integer from 4 to 15 seconds and resolution is 768P. Text-only needs a fixed ratio: 21:9, 16:9, 4:3, 1:1, 3:4 or 9:16. Use adaptive for frame generation. Reference generation accepts adaptive or a fixed ratio.

The examples explicitly set context_ir_enabled: false. Context IR is disabled for all new H3 tasks. Values sent in context_ir_enabled or prompt_expansion are ignored, including true. These fields alone do not cause rejection; other parameters are still validated. Leave aigc_watermark false. Do not send callback_url; query the task instead.

Replace the example.com media links below with public HTTPS URLs the service can read. A local file path is not a URL. In reference mode, an image must explicitly use role: "reference_image"; omitting its role defaults it to a first frame and can conflict with audio references. Do not put an API key in a media URL or frontend source code.

Native API: create a task

Text to video

curl https://tokvi.ai/v2/video_generation \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: h3-text-YOUR_UNIQUE_ID" \
  -d '{
  "model": "MiniMax-H3",
  "content": [
    {
      "type": "text",
      "text": "A misty valley at dawn, soft light, slow camera push forward."
    }
  ],
  "resolution": "768P",
  "duration": 5,
  "ratio": "16:9",
  "context_ir_enabled": false,
  "aigc_watermark": false
}'

First-frame video

curl https://tokvi.ai/v2/video_generation \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: h3-frame-YOUR_UNIQUE_ID" \
  -d '{
  "model": "MiniMax-H3",
  "content": [
    {
      "type": "text",
      "text": "The subject turns toward the camera as the background lights shimmer."
    },
    {
      "type": "image_url",
      "role": "first_frame",
      "image_url": {
        "url": "https://example.com/first-frame.png"
      }
    }
  ],
  "resolution": "768P",
  "duration": 8,
  "ratio": "adaptive",
  "context_ir_enabled": false,
  "aigc_watermark": false
}'

Reference image and two audio clips

curl https://tokvi.ai/v2/video_generation \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: h3-two-audio-YOUR_UNIQUE_ID" \
  -d '{
  "model": "MiniMax-H3",
  "content": [
    {
      "type": "text",
      "text": "Reference image 1 shows A on the left and B on the right. A uses the voice in audio 1; B uses audio 2. Fixed camera. A says: We are ready. B replies: We can go now. Only one character speaks at a time. No music."
    },
    {
      "type": "image_url",
      "role": "reference_image",
      "image_url": {
        "url": "https://example.com/characters.png"
      }
    },
    {
      "type": "audio_url",
      "role": "reference_audio",
      "audio_url": {
        "url": "https://example.com/voice-a.wav"
      }
    },
    {
      "type": "audio_url",
      "role": "reference_audio",
      "audio_url": {
        "url": "https://example.com/voice-b.wav"
      }
    }
  ],
  "resolution": "768P",
  "duration": 10,
  "ratio": "16:9",
  "context_ir_enabled": false,
  "aigc_watermark": false
}'

Save task_id from the create response, for example {"task_id":"task_xxx","status":"queued"}. Replace the unique request ID for each new logical generation. For an uncertain H3 request, keep the same idempotency key and identical body if you intentionally repeat it; check the original task first. A different key can create another billable task. This is not a guarantee for other models or an unlimited retention period.

Native API: query and retrieve the result

curl "https://tokvi.ai/v2/query/video_generation/$TASK_ID" \
  -H "Authorization: Bearer $TOKVI_API_KEY"

Set TASK_ID to the public task_id returned by Tokvi. Read task.status: queued, running, succeeded, failed or cancelled. Query the same ID every few seconds; honor rate-limit responses. After succeeded, download from task.content.url promptly because the URL can expire. On failure, inspect task.error and your task/billing logs.

Compatible API: keep its fields and statuses separate

If your tool uses /v1/videos, use prompt and seconds, save the returned id, and follow the compatible flow below. Its top-level status and content download endpoint differ from the native format. Both interfaces use your Tokvi key; the request format alone does not select a particular supplier.

Compatible API: 1. Create a task

Each submission may create a new billable task. If a connection drops, a request times out or no response arrives, check the task records in the console before submitting again. For H3, the same idempotency key and identical body reuse the existing task. A different key can create a new task; check other models separately.

curl https://tokvi.ai/v1/videos \
  -H "Authorization: Bearer $TOKVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-H3",
    "prompt": "A misty mountain valley at dawn",
    "resolution": "768P",
    "seconds": 4,
    "ratio": "16:9",
    "context_ir_enabled": false
  }'

Save the id from the successful response and use this public task ID for subsequent queries. A successful submission means the task was accepted, not that the video is ready.

2. Check task status

Replace task_xxx below with the id from the submission response:

curl https://tokvi.ai/v1/videos/task_xxx \
  -H "Authorization: Bearer $TOKVI_API_KEY"

The top-level status field uses queued, in_progress, completed and failed. Continue polling the same public task ID until the task reaches a final state.

  • Completed: download the video from /v1/videos/{id}/content using the same API key. The status response is task metadata, not the video file.
  • Failed: check error.message and error.code, and review the task record in the console.
  • Queued or in progress: wait several seconds before querying again. Increase the interval if rate limiting occurs.

Inputs and usage

The current integration supports 768P text-to-video, image-to-video and reference-to-video tasks. Each input mode has its own media and parameter limits. Reference video cannot be combined with first/last-frame inputs in the same request. The example above creates a 4-second video from text with no reference media and explicitly disables Context IR. Context IR remains disabled across all H3 channels for new tasks.

Output video, input video and images beyond the included allowance may be metered separately. New tasks do not enable or incur Context IR charges; existing tasks retain their original parameters and billing. Check all billing items in the model catalog; output duration alone does not determine every task’s total cost.

Billing and balance

The global site deducts charges from your USD balance based on actual usage. The model catalog shows customer prices and billing units. Depending on the model, charges may be based on input/output tokens, image counts, video duration or other task usage.

Asynchronous image and video tasks may reserve balance before execution and settle charges when complete. Check task status and billing records for the release of reserved funds after a failure. Ensure that both your account balance and key spending limit are sufficient before submitting a request.

Payment methods, top-ups and promotions are available only as shown in the console. CNY balances, redemption codes and orders from the China site do not automatically transfer to the global site.

Troubleshooting

  • Authentication failure: check the header format, key expiration and whether the key was issued on tokvi.ai.
  • Model unavailable or access denied: verify the model ID, key restrictions and selected group.
  • Wrong result format: Qwen Images uses data[].url; Wan Responses uses output[].content[].text; Wan Videos downloads through /v1/videos/{id}/content; H3 downloads through /v1/videos/{id}/content.
  • HTTP 503 or an empty response: retain the request ID and response Content-Type, check model availability, and contact support. Do not assume an accepted task should be submitted again.
  • Invalid parameters: adjust the request according to the error response. Supported parameters vary by model.
  • Insufficient balance: check your account balance, key spending limit and pending asynchronous tasks.
  • HTTP 429: the request was rate-limited. If the response includes Retry-After, wait for that interval. Reduce concurrency and polling frequency.
  • Video not returned immediately: save the task ID from submission and continue polling its status. Do not repeatedly create new tasks.

For troubleshooting, keep the request time, model name, public task ID and error code. Do not share complete API keys or input containing private information.

LET’S CONNECT

Let’s start a conversation.

Leave your details and our team will contact you. Name is required; provide a phone number or email.

tokvi@gmail.com

Your details will only be used to respond to this inquiry. Privacy policy