How it works
You send the provider’s normal request to Locus. Before the call, Locus places a hold on credits sized from your prompt and output budget. After the model answers, Locus charges for the usage the provider reports, never more than the hold, and releases the rest. Enable the model endpoint in Agent tools. Use a scoped agent key for a hosted runtime.Use an OpenAI-compatible client
1
Set the base URL
OpenAI-compatible base URL
2
Add your Locus credential
Set the client’s API key to your Locus credential.
3
Make the request
Send a unique
Idempotency-Key header and reuse it on retries.
/chat/completions accepts JSON and streaming requests.Direct request
Locus Pro Enterprise accepts the provider’s request body:Call a model
- The response headers carry the charge (
X-Locus-Credits-Charged), the remaining balance, and a call ID for status checks and support. - To cap a call’s charge, send
X-Locus-Max-Charge-Credits. Locus refuses the call before it starts if its hold would be larger. - Reuse the original idempotency key when retrying a call with an uncertain outcome.
Agent and framework access
MCP clients can call enabled inference tools through their existing connection, without streaming. Use REST when your application needs a streaming response. For model SDKs and agent runtimes, see Framework integrations. Locus Pro self-serve users enable inference under Tools and connect through MCP OAuth.Dynamic charges and streaming
Chat is charged from the usage the provider reports. The hold is sized from the prompt and the output budget (max_tokens).
- You are never charged more than the hold. If the usage would cost more, Locus absorbs the difference.
- If the provider reports no usable usage, or the request uses a feature Locus cannot price from usage, the call is charged the hold.
- A smaller
max_tokenslowers the hold, which helps when your balance or price cap is tight.
Streaming
A stream starts before its cost is known, so its headers show the hold amount. The settled charge comes later, in one closing billing event that Locus adds after the provider’s last event. OpenAI-compatible and Anthropic clients skip this event, so it does not change their output. The call status is the source of truth for the final charge and balance. Streams are not stored for replay. Reusing anIdempotency-Key after a stream started returns a 409 error with the original call ID, without a second charge. Use a new key for a new generation.
Next steps
Tools and pricing
Choose endpoints and inspect prices.
Node SDK
Read costs and handle errors in your application.