Netwrck logo Netwrck

Documentation

AI characters in a scene

Ask a character for a live reply mid-scene. Every reply is a paid model call.

A novel can stop mid-scene, send the player's line to a model, and display what the character answers. The reply arrives in a normal Ren'Py variable, so the rest of the scene is written the way any other scene is written.

Each live reply is one real model call billed to the signed-in player after they approve the in-game cost dialog: the provider's cost for the tokens actually used, plus 20%, rounded up to whole credits (1 credit = $0.01). Guests receive the authored offline fallback. Nothing about a live call is free, and a loop that asks in a `while` block spends on every pass.

Install the SDK in the engine

The statement lives in the renpy-js package @renpyjs/ai. The parser must know the statement before a script is compiled, and the runtime must have the handler installed before the scene runs.

// once, where the player is created
import { installAI, registerAIStatement } from '@renpyjs/ai';

registerAIStatement();
const ai = installAI(controller.runtime, {
  project: 'vnp_your_project_id',
  characters: [{
    id: 'mara',
    name: 'Mara',
    persona: 'Night nurse on ward nine. Tired, blunt, kind under it.',
    greeting: 'You again.',
    fallback: 'Mara says nothing.',
  }],
});

A scene where the character answers freely

`ai <character> <expression> as <variable>` sends the expression as the player's line and writes the reply into the variable. The variable holds text that is already escaped, so a reply can never inject Ren'Py text tags.

define mara = Character("Mara")

label ward_nine:
    scene bg ward
    show mara neutral
    mara "You again. Ask, then let me work."

    $ question = renpy.input("Ask Mara anything", length=200)

    ai mara question as mara_reply

    if _ai_ok:
        mara "[mara_reply]"
    else:
        mara "..."
        "She is not listening. ([_ai_error])"

    menu:
        "Ask something else":
            jump ward_nine
        "Let her work":
            jump corridor

What the endpoint does

POST /api/visualnovel/ai/character takes project, either an inline persona (character, name, persona, greeting, scenario) or netwrck_character naming one of your own netwrck characters, plus player_input, optional scene, history, model, max_tokens and session. It answers with text, renpy_text, model, usage, cost, billed, latency_ms and job_id.

It requires a logged-in account with owner, public or valid share access to the project. The call is charged to that reader, never silently to the author. A referenced netwrck character still belongs to the author, and a character marked adult is refused with 403 unless the reader allows adult content. GET /api/visualnovel/ai/characters lists your own characters and the current limits.

Default model is grok-4.5 at low reasoning effort. Overrides are limited to the models this server already routes; an unknown id is rejected rather than dispatched.

curl -X POST https://netwrck.com/api/visualnovel/ai/character \
  -H 'content-type: application/json' \
  -d '{"project":"vnp_x","character":"mara","name":"Mara",
       "persona":"Night nurse on ward nine.",
       "player_input":"Do you trust the captain?"}'

Price

Base model price plus 20%, on the tokens the call actually used, rounded up to whole credits. A short exchange on grok-4.5 is normally 1 credit; a long scene summary in the prompt costs more because the input tokens are larger.

The charge is written to the visual novel billing ledger with the provider cost, the markup and the job id, and is visible at /api/visualnovel/billing/ledger. If a reply comes back empty or unusable after the provider was already paid, that ledger row is refunded exactly once.

Every ai statement spends credits. Test with mode: 'offline' or dry_run: true, both of which are free.

Failure, timeout, rollback and saves

A failed or timed out call writes the character's fallback line and sets _ai_ok to False and _ai_error to the reason. The scene keeps running; nothing throws and nothing stalls. The server's deadline is 55 seconds and the SDK waits 75, so a call the server charged for is never abandoned by the client first.

Every request carries a request_id. The same request_id inside ten minutes is answered from the server's stored reply with replayed: true, without a second model call and without a second charge, so a retry or a lost response cannot bill twice.

A paid reply blocks rollback past it, so a player cannot rewind and be billed twice for the same moment. Identical questions inside one playthrough are answered from a memo cache instead of a second call, which also means the same question in the same scene gives the same answer.

A save stores the reply like any other variable, so loading shows the same line without calling again. Conversation memory is per playthrough and capped at 12 turns server side, 6 exchanges client side by default.

Rate limits

One request per second per account with a burst of four, and at most two calls in flight per account. Player input is capped at 2 KB, the scene summary at 4 KB, the persona at 6 KB, output at 600 tokens, and a reply is trimmed to four lines and 900 characters.

There is no daily or per-project spending cap: the limits above shape the rate, the account balance is the ceiling. The SDK's maxCalls and budgetCredits options are the per-playthrough guard, and they are client side.

Welcome Back to Netwrck



Forgot password?

Don't have an account? Sign up here

Join Netwrck - AI Art & Chat

Create AI art, search the web, generate videos and edit photos. Get started with your free account today!



Already have an account? Login here

Netwrck Unlimited

Voice Chat - Character Creation - Art Generation

30 day Money Back Guarantee.


Art Generator Settings


Resolution
Aesthetic Elf Styles
Anime Anime
Photographic Photographic
Digital Art Digital Art
Comic Book Comic Book
Fantasy Art Fantasy Art
Neon Punk Neon Punk
Knight Knight
Ethereal Ethereal
Low Poly Low Poly
Stunning Stunning
Line Art Line Art
Cinematic Cinematic
Wanderer Wanderer
Beggar Beggar
Seductive Seductive
Warrior Warrior
Steampunk Steampunk
Japanese Japanese
Western Western
Handsome Handsome
Pop art Pop art
Abstract Abstract
Impressionist Impressionist
Fauvist Fauvist
Beauty grace Beauty grace
Evil Evil
God God
Demon Demon
Masculine Masculine
Feminine Feminine
Majestic Majestic
Mage Mage
Princess Princess
King King
Sweet Sweet
Fantasy Fantasy

AI Generated Images


Community Images


New AI

person
This is what your AI will say when someone first chats with them
Help others understand what your AI character is about

AI Settings

Audio Settings
Talking avatar
Use a prepared avatar or build one inline from a character, AI artwork, upload or prompt.
Character calls

Local is free (browser speech + your chat model + on-device TTS). Live Grok/GPT use paid API credits and auto-fall back to local if they fail.

1.0x

Translation

For Chinese: hanzi + pinyin per word, tap any word to hear it spoken locally.


Art Generation

When enabled, AI can automatically generate art based on conversations

Prepended to art prompts when Make Art runs.
Only applies when GPT Image 2 is selected. GPT Image 2 chat art consumes credits.

High Resolution

LTX 2.3 Image to Video

Selected image
Pick any generated image and turn it into a video.
$0.58 · 58 credits
Your latest request will appear here.

Saved Requests

Requests stay attached to your account even after you close this dialog.
No video requests yet.

Find an AI to chat with

No AI characters found.

Help Everyone Know You

person

Share Image

Consider our affiliate program to earn!

Copy

Reddit

X

Facebook

LinkedIn

NETW Coin is live!

AI should be owned by everyone.
So we are building a new AI economy together.
Thank you for being on this journey with us!
Read More

Netwrck Android App

Our Android App Is Available Now - Please Check it out!

New Post

Add Netwrck Credits

Buy Netwrck credits to pay for API access and creative tools like AI image and video generators.

Current Balance: $0.00
Custom:

Sign in to keep chatting

You have used your messages. Sign in to continue this conversation and keep your chat history.

No card required.

AI Characters in room

Search Characters