AI
Ask ForgeCast's AI, paid with the streamer's credits.
Functions
ai.ask(prompt, opts, callback)
Ask ForgeCast's AI. The answer comes later: callback(answer), or callback(nil, why) when it
failed (no credits left, offline, the streamer stopped it…). Each request is paid with the
streamer's AI credits and shows under AI workers. A plugin may have 2 requests waiting at a time
and make 30 an hour.
Name
Type
Returns integer id
obs.screenshot(nil, { width = 960 }, function(pic)
ai.ask("What's happening in this game?", { image = pic }, function(answer) ui.notify(answer) end)
end)ai.classify(text, labels, callback)
Sort a text into one of your labels: callback({ label = "question", confidence = 0.9 }).
Costs the same as ai.ask and counts toward its limits.
Name
Type
Returns integer id
ai.classify(chat.text, { "question", "joke", "spam", "other" }, function(r)
if r and r.label == "question" then ui.notify("Question: " .. chat.text) end
end)ai.translate(text, language, callback)
Translate a text into another language, keeping names, @handles and emoji. Costs the same as ai.ask and counts toward its limits.
Name
Type
Returns integer id
AiSession:ask(prompt, opts, callback)
Ask, with the conversation so far: the question and its answer are remembered for the next one.
Name
Type
Returns integer id
AiSession:history()
The conversation so far, oldest first.
Returns AiTurn[]
AiSession:forget()
Forget the conversation and start over.
ai.session(opts)
A conversation with the AI that remembers what was said: a co-host that knows the last few questions. Each ask is an ai.ask (same cost and limits).
opts:AiSessionOptions, optional
Returns AiSession
local cohost = ai.session{ system = "You are a cheerful pirate co-host. One sentence." }
cohost:ask("Say hi to chat", function(a) print(a) end)Types
Open a type to see its fields; type names above link here.

