gizai:studio
the models of an app (Studio): chat, image and video models held on one GPU and taken in turn, and an agent's model: this computer's, the giz.ai account's or an OpenAI-compatible API's.
import * as Studio from "gizai:studio";Types
Studio
type Studio = { sys: System; hub: Hub.Hub; engine: Ref<Vec<Engine>>; chatting: Ref<string>; painter: Ref<Option<ImageModel>>; filmer: Ref<Option<VideoModel>>; turn: Task.Channel<i64>; needs: Ref<Map<string, i64>>; }The models of an app, each loaded at its first use and kept: the chat model (chatting names the one loaded, ""
none; another chat model replaces it), the image and the video model. A Studio is shared, as a closure captures it:
its models are in Refs.
sys:gizlang_system.Systemhub:gizlang_hub.Hubengine:Ref<Vec<M32.Engine>>chatting:Ref<string>painter:Ref<_gizlang_sdk_core.Option<M31.ImageModel>>filmer:Ref<_gizlang_sdk_core.Option<M50.VideoModel>>turn:gizlang_task.Channel<i64>— Its one token: a chat turn, a picture or a clip runs while it holds it (alone).needs:Ref<_gizlang_sdk_collections.Map<string, i64>>— The most device bytes each model ("chat", "image", "video") used to load and run, measured (Gpu.peak).
Choice
type Choice = { kind: string; name: string; }Where a model name points: kind "local" (this computer's chat model), "giz" (a model of the giz.ai account) or
"api" (a model of the OpenAI-compatible API of AI_URL), and the model's name there ("": that kind's default).
kind:stringname:string
Functions
studio
function studio(sys: System): Studio throws stringThe models of this computer: the chat model CHAT_MODEL (qwen3.5-4b), the image model IMAGE_MODEL (z-image-turbo), and LTX-2.5 (LTX_REPO, or the ComfyUI models folder VIDEO_MODELS) with its text encoder on the same GPU, or served at VIDEO_ENCODER (HOST:PORT). A model loads at its first use, and one that is not here yet is downloaded then.
Effects: fail, write, io.
choose
function choose(name: string, aiModel: string, aiUrl: string, signedIn: bool): ChoiceThe choice of name, else aiModel (AI_MODEL): "local:NAME", "giz:NAME", and any other name a model of the API.
With no name: the API when aiUrl (AI_URL) is set, else giz.ai's default when signedIn, else the local default.
Effects: fail.
gizOrLocal
function gizOrLocal(sys: System, giz: Result<Agent.Model, string>, local: Agent.Model): Agent.ModelThe default model when giz.ai is: giz (the account's default, made with one refresh of the sign-in and one model
list), else local when giz.ai cannot be used now, as an expired sign-in, with one stderr line of why. A program
with no model named starts either way.
Effects: fail, io.
chosen
function chosen(names: Vec<string>, asked: string): i64The place in names of the model a request asks for: the first when it names none, and a name may carry its
provider ("gizstack/q27-4"); -1 when the server serves no such model.
Effects: fail.
Methods
Studio.chat
function Studio.chat(self: Studio, turns: Vec<string>, each: (text: string) => void): string throws stringThe chat model's answer to turns: the person's and its own texts in turn, the person's first and last. Each piece of
the answer goes to each as it comes.
Effects: fail, read, write, console, io.
Studio.model
function Studio.model(self: Studio, name: string = ""): Agent.Model throws stringThe agent's model (gizai:agent) that name names, else AI_MODEL (choose): "local:NAME" this computer's chat model
NAME (CHAT_MODEL when NAME is ""), loaded at its first turn; "giz:NAME" model NAME of the giz.ai account that
giz auth login signed in (its first chat model with tools when NAME is ""); any other name a model of the API of
AI_URL (Agent.endpoint). With no name at all: AI_URL's model when it is set, else giz.ai's when signed in, else the
local qwen3.5-4b, and one line on stderr names the choice.
Effects: fail, read, write, console, io.
Studio.models
function Studio.models(self: Studio): Vec<string>The model names Studio.model takes, for a picker: "local:NAME" for each chat model this computer holds ready,
"giz:ID" for each chat model of the giz.ai account when signed in, and each model of the API of AI_URL when it is
set. A source that does not answer lists nothing.
Effects: fail, read, write, console, io.
Studio.image
function Studio.image(self: Studio, prompt: string): bytes throws stringA picture of prompt, as PNG.
Effects: fail, read, write, console, io.
Studio.listen
function Studio.listen(self: Studio, sound: OpenAi.Sound): string throws stringThe words spoken in SOUND, as the speech-to-text model LISTEN_MODEL of the model API (AI_URL, AI_API_KEY) hears them. This computer has no speech-to-text model of its own yet.
Effects: fail, read, write, console, io.
Studio.speak
function Studio.speak(self: Studio, text: string): OpenAi.Sound throws stringTEXT spoken by the text-to-speech model SPEAK_MODEL of the model API (AI_URL, AI_API_KEY), in its voice SPEAK_VOICE ("" the model's own).
Effects: fail, read, write, console, io.
Studio.dropChat
function Studio.dropChat(self: Studio): voidEach model leaves the GPU and gives its buffers back (Gpu.memory then counts them free).
Effects: fail, read, write, console, io.
Studio.dropImage
function Studio.dropImage(self: Studio): voidThe image model leaves the GPU, so another engine can use its memory.
Effects: fail, read, write, console, io.
Studio.dropVideo
function Studio.dropVideo(self: Studio): voidThe video model leaves the GPU, as dropImage does the image model.
Effects: fail, read, write, console, io.
Studio.loaded
function Studio.loaded(self: Studio): Vec<string>The models loaded now ("chat", "image", "video").
Effects: fail, read.
Studio.video
function Studio.video(self: Studio, prompt: string): bytes throws stringA video of prompt (videoRequest), as MP4.
Effects: fail, read, write, console, io.