Package 'wan27'

Title: Official Server-Side R Client for 'Wan27' AI Image and Video Generation
Description: Server-side R client for the 'Wan27' (<https://wan2-7.io/>) AI image and video generation API and MCP workflow ecosystem (<https://wan2-7.io/mcp/>). Provides functions to inspect account eligibility and credit balances, list supported models and input schemas, estimate credit costs before spending, submit idempotent generation requests with explicit request IDs, and poll task states. Uses 'jsonlite' and 'curl' when installed, with a dependency-free base R fallback for offline testing and lightweight environments.
Authors: Wan27 Team [aut, cre]
Maintainer: Wan27 Team <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-28 16:58:06 UTC
Source: https://github.com/NotUsingGithub/wan27-r

Help Index


Read Account Eligibility and Credit Balance

Description

Queries GET /api/v1/account/ to inspect active subscription eligibility and available credits on https://wan2-7.io/.

Usage

wan27_account_balance(client)

Arguments

client

A wan27_client object.

Value

A list representing the JSON response from the service.


Create a Wan27 API Client

Description

Creates a configured client for https://wan2-7.io/api/v1/. Supply an existing access token from your server-side environment. See https://wan2-7.io/mcp/guide/ and https://wan2-7.io/pricing/ for authentication and credit details.

Usage

wan27_client(
  token = Sys.getenv("WAN27_ACCESS_TOKEN"),
  timeout = 120,
  handler = NULL
)

Arguments

token

Character scalar access token. Defaults to Sys.getenv("WAN27_ACCESS_TOKEN").

timeout

Numeric timeout in seconds (greater than 0 and at most 120).

handler

Optional custom HTTP transport function used for offline unit tests.

Value

An object of class "wan27_client".

Examples

client <- wan27_client(token = "wan27_test_token_example")
print(client)

Estimate Credits Before Creating a Paid Generation Task

Description

Sends POST /api/v1/estimates/ to calculate the credit cost of an input payload without creating a paid task. See https://wan2-7.io/pricing/.

Usage

wan27_estimate(client, input)

Arguments

client

A wan27_client object.

input

Named list of model parameters (must include modelId and prompt).

Value

A list containing the estimated credit cost.


Create an Authorized Paid Generation Task

Description

Submits an idempotent generation task to POST /api/v1/generations/ on https://wan2-7.io/. Requires an explicit request_id so network timeouts can be safely inspected and retried without double-charging.

Usage

wan27_generate(client, input, request_id)

wan27_generate_image(
  client,
  prompt,
  request_id,
  model_id = "wan27-text-to-image",
  ...
)

wan27_generate_video(
  client,
  prompt,
  request_id,
  model_id = "wan27-text-to-video",
  ...
)

Arguments

client

A wan27_client object.

input

Named list of generation parameters.

request_id

Character scalar idempotency key (16–128 characters).

prompt

Character scalar text prompt for helper wrappers.

model_id

Character scalar model identifier.

...

Additional named parameters forwarded to input.

Value

A list containing the created task record (including task$id).


List and Inspect Generation Tasks

Description

wan27_list_tasks() lists recent tasks with optional pagination, and wan27_get_task() retrieves the current status and outputs of a single task. Only status == "succeeded" indicates completion.

Usage

wan27_get_task(client, task_id)

wan27_list_tasks(client, limit = 20L, cursor = NULL)

Arguments

client

A wan27_client object.

task_id

Character scalar task identifier.

limit

Integer between 1 and 50 (default 20).

cursor

Optional character scalar pagination cursor from a previous response.

Value

A list representing the task or task collection.


List Supported Wan27 Models and Schemas

Description

wan27_models() lists currently supported models, while wan27_model() fetches the input schema for a specific model_id.

Usage

wan27_models(client)

wan27_model(client, model_id)

Arguments

client

A wan27_client object.

model_id

Character scalar model identifier (for example, "wan27-text-to-video" or "wan27-text-to-image").

Value

A list representing the JSON response from the service.


Return Canonical Wan27 Documentation and Service URLs

Description

Returns a named list of official Wan27 documentation, MCP, CLI, pricing, and API endpoint URLs.

Usage

wan27_urls()

Value

A named list of character strings containing URLs for https://wan2-7.io/, https://wan2-7.io/mcp/, https://wan2-7.io/mcp/guide/, https://wan2-7.io/cli/, and https://wan2-7.io/pricing/.

Examples

urls <- wan27_urls()
urls$website
urls$mcp