Repository navigation
OnlyWorlds Unity SDK 0.37.0
The AI door: one route a tool calls a model through, by a named use, with the token that opens only it. Parity with
the TypeScript SDK 4.141.0, its test vectors ported. A minor release because it adds public API (below).
Added
OWClient.AiUsesAsync(): the AI uses onlyworlds.com runs (GET/account/ai), each anOWAiUse: its slug,
owner, provider (OWAiProvider:anthropicorjev), model and effort, the hash of its system prompt, what its
body may hold, its answer cap, the rating a call needs left today to run (RatingNeed), its price, its daily
ceiling, this account's calls left today, and whether it is on. Reading it spends nothing.OWClient.AiAsync(use, body, idempotencyKey): one call of a listed use (POST/account/ai/{use}), metered on
the account's token rating and then its own saved AI key, asAskAsyncandSortAsyncare. The body is the use's
ownJObject, in its wire spelling, sent as given, and the answer is the use's own, as served (OWAiAnswer.Answer).
Theaskandsortuses are typed:AiAsync(OWAiAskBody)answersOWAiAskAnswer,AiAsync(OWAiSortBody)
answersOWAiSortAnswer. Every answer addsUseRemaining(null when the use has no daily ceiling) andWasReplay,
read from theIdempotent-Replayheader. The client's name goes asX-OW-Client. The use is checked as one path
segment and the key as 1 to 200 characters before anything is sent.- With an idempotency key, a retry is safe: the same key and body answer the first answer again and bill nothing,
and so does a refusal the provider billed (answer_not_parsed, or a 502 after a billed answer). A key whose first
call is still running answers 409idempotency_in_flight: retry with the same key and body a few times at most,
and never mint a new key to get past it. The client never retries on its own. - An AI door token at sign-in:
CompleteSignInAsync(pending, url, ct, aiUses, aiLifetimeMinutes)asks the code
exchange for anow_a_token that opens onlyAiUsesAsyncand the uses it names, as the person and on their token
rating, until midnight UTC at the latest. It comes back asOWSignInResult.AiToken(OWAiToken) beside the account
token, and is null when none was asked or the server answered none. Both options come after the cancellation token
and are optional, so every present call compiles and sends what it sent. The exchange spends its code whatever it
answers, so a list the SDK can see is wrong (not 1 to 8 names, a name that is not one path segment, a lifetime
outside 1 to 1440 minutes or without uses) is refused before anything is sent, and the sign-in stays pending. A name
the server does not run is its 422, and the code is then spent. OWSignInError.Param: the field the server named when it refused the code exchange, as on the TypeScript SDK's
OwSignInError.param:ai_usesorai_lifetime_minuteson a 422 that refused the AI door token, null when the
answer named none. The error kept the status and code and dropped the field before, so that refusal could not be told
from any other 422.OWClient.MintAiTokenAsync(uses, lifetimeMinutes, name): trade an account token down to an AI door token
(POST/account/tokenswithai_uses), answered asOWMintedAiToken, the token's row with the token once. It
belongs to the token that minted it: revoking that one revokes it too. The uses are required, so a call without
them never reaches the route that would mint a full account token.OWAccountToken.AiUses, on an AI door token's row.- Five refusals by name on
OWApiError:IsUseCeiling(429use_ceiling: the use's calls for the day are
made),IsUseInFlight(429use_in_flight: another call to this use is running; waitRetryAfter),
IsUseNotGranted(403use_not_granted: an AI door token called a use it does not name),IsWrongAudience(401
wrong_audience: a token on a route it does not open) andIsAnswerNotParsed(422answer_not_parsed: the use's
model answered off its promised shape twice, billed to the use's own budget; do not retry).IsRetryablereads
use_ceilingas it readsquota_exceeded: not before midnight UTC.
Changed
- An error whose envelope says
"param": nullreadsOWApiError.Paramas null, as the TypeScript SDK reads it;
it read as an empty string before. The same forMessage,Type,CodeandDocUrlwhen the server sends null.
Deprecated
AskAsyncandSortAsync, in favour ofAiAsync(OWAiAskBody)andAiAsync(OWAiSortBody): the same answers,
with the use's meter (UseRemaining) and an idempotency key, under which a retry is answered from the first call and
billed nothing. Both are marked[Obsolete]as a warning, not an error, and keep working, unchanged, on their own
routes.