ai package). It gives
you a model for one user, and puts the call’s receipt
on the result as providerMetadata.atlaso.
ai 6 and 7 both work. ai 7 itself needs Node 22 or newer. For Responses
models, also install @ai-sdk/openai.
A model per request
CallcreateAtlaso() once, at module scope: it holds your key and no user.
Inside each request, after your sign-in check, call forUser(userId).chat(model).
streamText, the receipt is on each step’s finish-step part. The
streaming route example sends it to
useChat.
forUser(id).responses(model)gives a Responses model (needs@ai-sdk/openai). If your bundler cannot load that package on demand, pass itscreateOpenAItocreateAtlaso({ createOpenAI }).forUser(id, { memory: "off", tags: { feature: "chat" } })sets the same per-call options as the core SDK.forUser(id).memoryis the memory API for that user.- Stream cost:
createAtlaso({ includeUsage: true })asks the stream for usage, so the receipt has its cost. Left unset, nothing is added to your request and a stream receipt saysusage_not_requested.
Memory tools for agents
forUser(id).tools.aiSdk() gives remember, list_memories, and the read-only
search_memories tool bound to that user. Search takes a query and an optional
limit of 1 to 20. There is no user argument for the model to fill in. forget is
added only with { allowForget: true }, and it can delete only facts returned by
list_memories or named in a receipt you pass with { receipt }.
Your own provider, per-call headers
If you keep your own@ai-sdk/openai-compatible provider, build it once
without a user and pass the user’s headers on each call. You get no receipt this
way; use forUser(id).chat() for receipts.
Choose providers
routing() from atlaso/ai-sdk sets which providers may answer, in what
order, and whether a backup may answer. Pass it as providerOptions on a
chat() model. It takes the same options and runs the same checks as the
core routing(), and sends nothing when no
option is set. Responses models (responses()) do not carry it: the adapter
throws routing_not_supported instead of dropping it.
providerOptions: { atlaso: { ...routing(options).atlaso, reasoningEffort: "low" } }.
Limits
- There is no receipt before the first token arrives, and none for a stream you abort: the AI SDK sends no finish part then.
providerMetadata.atlasoreplaces any metadata under the same key from the provider package.- If you pass your own core client with
createAtlaso({ atlaso }), also pass the samefetchthere if you gave it a custom one.