Not yet released. This guide describes implemented changes awaiting rollout. Availability requires the corresponding backend and dashboard release.
Goal
Give your agent models, pay for them in AI credits or with your own provider key, and handle each way a call can be refused.Prerequisites
- An agent with the models it may use listed under
models:instackshift.yaml. - AI credits in your account, or your own Anthropic or OpenAI key saved in the agent’s settings.
Workflow
1
List each model under
models: with its provider. A call to a model that is not listed is refused with 403 model_not_allowed.2
Choose how the agent pays in
payWith: credits or own_key. For own_key, save the key in the agent’s settings. The agent never sees it.3
In the agent’s code, use
agent.anthropic() or agent.openai(). They return the official clients, already pointed at StackShift and signed in with the run token. Or set the base URLs yourself, as below.4
Pass
max_tokens on every call. A call without it is refused.5
Set budgets for the month and for one run so a mistake cannot spend more than you chose.
What the agent has
Inside the agent,ANTHROPIC_BASE_URL is https://api.stackshift.cloud/ai and OPENAI_BASE_URL is https://api.stackshift.cloud/ai/v1. The credential is a run token: it is bound to this agent and the place it runs, lasts one hour, and a new one arrives with each event. The SDK keeps it in memory and, where it can, in a private file in the agent’s home folder for the official clients. It is never in an environment variable. It stops working the moment the agent is stopped.
The endpoints are the ones the official SDKs call: POST /ai/v1/messages (streaming, tool use and prompt caching pass through), POST /ai/v1/responses and POST /ai/v1/chat/completions. Errors come back in the provider’s own error shape.
Paying with credits or your own key
Before each call StackShift reserves credits for the input plusmax_tokens at the output price. After the call it settles on what the provider reports. If a stream is cut, it settles on what was seen and releases the rest.
Providers today are Anthropic and OpenAI. The agent’s requests go to the provider and model it asked for.
- Credits: charged at the same rates as Stackie. One credit is $0.001. Top up in Naira or US dollars from your wallet.
- Your own key: StackShift charges no tokens. Your provider bills you. The agent’s budget still counts the call at list price so the number means something, and your account’s own-key spend limits still apply.
Limits per call and per run
max_tokensis required, and calls above 64,000 output tokens are refused by default.- At most 200 model calls in one run.
- A run lasts at most 30 minutes by default.
From your own code outside StackShift
Code that does not run as an agent can use the same endpoints with an AI project key that has the scopeai:inference. See “Standalone AI projects and application keys”.
Expected result
Model calls work with the official SDKs unchanged. Each call is metered, counted against the run, month and account limits, and listed on the run’s page with its model, tokens and credits.
Common failures
Related guides
Budgets, stopping and runaway protection
Three budgets, a Stop button that halts everything at once, and layers that stop an agent that loops or fails.
The agents SDK for TypeScript and Python
The packages
@stackshift-cloud/agent and stackshift-agent give your code events, governed actions, StackShift calls, state, model clients and adapters for the Claude Agent SDK and the OpenAI Agents SDK.