You will learn#
- how to connect an AI service with your own API key;
- how the models and their prices are found;
- how to ask for a text, and why it waits for you;
- what never leaves your computer.
The idea#
Stuarty does not sell or resell AI. You bring your own account, and Stuarty calls the service with your key. A connection to a provider is a connection like any other: it may reach only the hosts it lists, and its key is kept encrypted on your machine and is never shown again.
The first two providers are OpenAI (the Chat Completions API) and Anthropic (the Messages API). Anthropic is reached with an API key only: Stuarty never offers a login with a Claude subscription. Midjourney is not supported, because it has no official API.
Two rules keep the cost in your hands:
- The price is shown before anything runs. A text is a job with an estimate. The estimate counts the largest answer you allowed, so it is an upper bound.
- A person says yes. An agent can prepare a text; it waits on the Approvals page until you approve it or until a rule you wrote does. A cost ceiling you set always wins, and an approval does not lift it.
In the app#
Connections shows one card for each AI provider, with the status Connected or Not connected, a link to where to find the key, and these actions:
- Save the key connects it with an API key (stored encrypted, never shown again); Sign in with ChatGPT or Sign in with OpenRouter connect without a key to copy.
- Check the key tests it, and Show the models lists what the provider offers, with the limits of each and its price.
- Set the price saves the price of a model, and the card shows what was Spent today.
- A sign-in that the provider no longer accepts says Needs sign-in; nothing was deleted, and Sign in again fixes it.
Below the providers are the cards for social networks and blog destinations, and the list All connections, with the exact hosts each one may reach, Test and Remove.
Prices#
No price is built into Stuarty. When a provider publishes a price with its models, Stuarty uses it. OpenAI and Anthropic publish none, so you set the price of each model you use, from the provider's own price page, on the Connections page or with provider:price. A model with no price is refused with E_PRICE_UNKNOWN: Stuarty will not guess a price of zero.
Only a person in the app can set a price, because a lower price would lower every estimate. The local token an agent holds is refused.
A price has a unit. A text is priced per million tokens (input and output). An image is priced per image (--unit image --unit-micros <millionths of the currency>), and a voice-over per million characters of its text (--unit mchar). A price in the wrong unit counts as no price.
Images and voice#
OpenAI makes images (POST /images/generations) and speech (POST /audio/speech). Anthropic has neither, so it stays a text provider. Both are jobs, like a text: they show an estimate, wait for you, and cost what the price you saw says.
- An image or a voice-over lands in your library. It is a file like any other, kept once by its content, and it remembers where it came from: the provider, the model, the prompt, what it cost and who asked. You find it with the origin filter Generated of Images, Videos and Sounds (a voice-over is a sound), and you use it in a project like any file.
- The Generate dialog (Images for an image, Sounds for a voice-over, Videos for a clip) asks for the connection, the model, the prompt (or the text to read and the voice), and shows the estimate before anything is submitted.
- The files are checked. A result that is not a PNG, a JPEG or a WebP (or not the audio format you asked for) is not kept. A result that the provider hands over as a link is fetched only from a host the connection lists.
- A refused prompt, a rate limit and a request that took too long are three different errors. A batch of images that only partly arrives keeps what arrived and costs what arrived.
- Say it is AI. Under the usage policy of OpenAI, a voice it makes must be disclosed as AI-generated to the people who hear it. Stuarty does not clone a voice from a recording of a person.
stuarty provider:price --provider openai --model an-image-model --currency USD --unit image --unit-micros 40000
stuarty image:generate --project prj_7k2m9x4q1b --connection con_0123456789 --model an-image-model --prompt "A red fox in the snow" --count 2 --dry-run
stuarty voice:list con_0123456789
stuarty voice:generate --project prj_7k2m9x4q1b --connection con_0123456789 --model a-voice-model --voice alloy --text "Welcome to the channel." --format wavRemove a background or generate inside an image#
In the image editor, Remove background and Generate in the toolbar use the same kind of connection and the same prices (per image). OpenAI has no operation named "remove background": Stuarty asks its image edit endpoint to keep the subject and make the rest transparent, and the model decides how well it does.
- The picture leaves your computer. Remove background sends the picture of the layer to the provider you choose, and the dialog and the approval request say so and name the provider. Generate sends only the prompt. Nothing is sent before you see the estimate and approve it; a connection that does not accept pictures cannot be chosen for a removal.
- The result is an ordinary layer. The layer keeps its place, name and effects and gets the new file; if the new picture has other proportions it is fitted inside the old box, never stretched. A generated picture is a new layer that covers the canvas or the layer you picked. One Undo takes either back, and the original file is never changed.
- A cut-out with no transparency is not applied. If the provider answers a picture that has no transparent pixel, the layer is left alone; the file is kept in your library with its origin and you pay for it, because the provider billed the request.
- A conflict is not an overwrite. If someone else changed the layer while you were deciding, the result stays in the library and the job says so.
stuarty image:model-edit --project prj_7k2m9x4q1b --image img_7k2m9x4q1b --operation remove_background --connection con_0123456789 --model an-image-model --layer lyr_7k2m9x4q1b --dry-run
stuarty image:model-edit --project prj_7k2m9x4q1b --image img_7k2m9x4q1b --operation generate --connection con_0123456789 --model an-image-model --prompt "A snowy forest, soft light"A connection for a removal must accept image, so connect it with --accepts text,image.
Video#
A short clip is made the same way, with one difference: it always waits for you, whatever the estimate is, because a video costs far more than an image. Only a rule you wrote on the Approvals page can lift that wait, and a cost ceiling still refuses what is above it.
Video comes from Google through the Gemini API, with your own API key from Google AI Studio (the API keys page, aistudio.google.com/apikey, which the card of the provider also names): connect it with connection:add --kind google and a model that makes video (gemini-omni-1.2-flash, 3 to 15 seconds, 16:9 or 9:16). Google lists its price per second of video on its pricing page; Stuarty ships no price, so add the one you read there with provider:price and the estimate and the approval show it. A clip is not charged by Stuarty: Google bills your key.
- The clip is generated in the background. Stuarty sends the request once, keeps the task number of the provider with the job, and asks for the result every few seconds. If you restart the app or the server meanwhile, the job picks the same task up and does not send the request again, so you are not charged twice. The only moment a crash could cause a second charge is the instant between the provider's answer and the write of that number to disk.
- Cancel asks the provider to stop. If it confirms, the job costs nothing; if it does not, the job is recorded at its estimate, because the provider may have charged for the work already done. Google does not say that a stopped, failed or blocked clip is free, so with Google such a job is recorded at its estimate too.
- A first frame can be an image of the project: the clip starts from it. The image is sent to the provider only after you approve.
- The clip lands in your library as a file with its origin (the provider, the model, the prompt, the cost and who asked), is probed and gets a proxy and a thumbnail like any import, and goes on a timeline like any file.
- Say it is AI. A generated clip may need to be disclosed as AI-generated where you publish it; the usage policy of the provider says how.
A price per second of video is set with --unit second --unit-micros <millionths of the currency per second>.
stuarty provider:price --provider google --model gemini-omni-1.2-flash --currency USD --unit second --unit-micros 70000
stuarty video:generate --project prj_7k2m9x4q1b --connection con_0123456789 --model gemini-omni-1.2-flash --prompt "A red fox in the snow" --seconds 6 --aspect 9:16 --dry-runQuick start#
- Open Connections, find the provider, and paste your API key under Save the key.
- Choose Show the models, then Set the price for the model you want.
- Ask an agent for a text, or run the command in the other tab. Approve it on the Approvals page.
# the base address is on the page of the provider that explains its API
echo $OPENAI_API_KEY | stuarty connection:add --kind openai --label OpenAI --endpoint <base address of the API> --accepts text
stuarty provider:models con_0123456789
stuarty text:generate --project prj_7k2m9x4q1b --connection con_0123456789 --model a-model --prompt "Write a caption" --dry-run--dry-run shows the estimate and writes nothing. Without it the job waits for approval and answers with its estimate.
Sign in instead of pasting a key#
Two providers can be connected with a sign-in in the browser. Open Connections, find the provider and choose the sign-in button.
- Sign in with ChatGPT uses your ChatGPT plan, within the limits of the plan, through the sign-in OpenAI documents for open source and local applications. Stuarty asks OpenAI for access in your name, you accept on the page of OpenAI, and the plan is used for text. OpenAI accepts the sign-in only at
http://127.0.0.1:<port>/auth/callback, so open Stuarty at127.0.0.1on the computer where it runs (the desktop app and a local server do). A server on another machine, or any server in network mode, refuses this sign-in: use an API key there. The plan is for text only, so a ChatGPT sign-in cannot make an image or a voice-over; connect OpenAI with an API key for those. A plan has no price per token, so its models show a price of zero and no ceiling stops them. - Sign in with OpenRouter makes a key of your OpenRouter account, which Stuarty keeps like any pasted key. It spends your OpenRouter credits, and the models show the price OpenRouter publishes.
Either way the tokens or the key go straight into the vault of this machine: no page, command, tool or log shows them, and an agent cannot start, finish or remove a sign-in, only a person in the app can. The access of ChatGPT is renewed by itself before it expires. If the provider stops accepting it, the card says Needs sign-in, nothing is deleted, and Sign in again brings it back. There is no sign-in with a Claude subscription: Anthropic is reached with an API key only.
What the answer is#
The text a model writes is untrusted text: an agent that reads it sees it inside a marked block and never as an instruction. The text is stored on the job, with the model, the tokens and the real cost, and you read it with job:show or job_get. The real cost is recorded in the ledger of the day, which the Connections and Approvals pages show.
What never leaves your computer#
- The key stays in the vault. No page, command, tool or log shows it.
- A provider that fails gets a short, fixed message: the body of its error is never shown, because it could repeat your key or your prompt.
- With no connection, Stuarty opens no outbound connection.