> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paywithlocus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Model inference

> Pay for model calls from the same Locus balance you use for tools.

Run model inference and paid tools through one balance. Locus returns the cost of each model call alongside the remaining credits, so you can track the full cost of an agent task.

Enable the model endpoint in **Agent tools**. Use a scoped [Agent Connection](/locus-pro/connect-agents#enterprise-service-credentials) for a hosted runtime.

## Direct request

Locus Pro Enterprise accepts the provider's request body:

```bash title="Call a model" theme={null}
curl --fail-with-body --include \
  --request POST \
  --url https://api.paywithlocus.com/api/wrapped/credits/openai/chat \
  --header "Authorization: Bearer $LOCUS_AGENT_CONNECTION" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $(uuidgen)" \
  --data '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Summarize this request."}],
    "max_tokens": 120
  }'
```

| Response header | Value |
| - | - |
| `X-Locus-Credits-Charged` | Cost of this call |
| `X-Locus-Credits-Balance` | Remaining balance |

Reuse the original idempotency key when retrying a call with an uncertain outcome.

## Use an OpenAI-compatible client

<Steps>
  <Step title="Set the base URL">
    ```text title="OpenAI-compatible base URL" wrap theme={null}
    https://api.paywithlocus.com/api/wrapped/credits/v1
    ```
  </Step>

  <Step title="Add your Locus credential">
    Set the client's API key to your Locus credential.
  </Step>

  <Step title="Make the request">
    Send a unique `Idempotency-Key` header and reuse it on retries.
    `/chat/completions` accepts JSON and streaming requests.
  </Step>
</Steps>

## Agent and framework access

MCP clients can call enabled inference tools through their existing connection. Use [Framework integrations](/locus-pro/frameworks) for model SDKs and agent runtimes.

MCP supports non-streaming tool calls. Use REST when your application needs a streaming response. Locus Pro self-serve users enable inference under **Tools** and connect through [MCP OAuth](/locus-pro/individual/connect-agents).

## Dynamic charges and streaming

Locus quotes the model and request before dispatch. The charged amount is that quote, rather than a recalculation from final token usage.

| Request | When credits are charged |
| - | - |
| Non-streaming | On success; an earlier failure releases the reservation |
| Streaming | When the provider accepts the stream, before the first response byte |

<Warning>
  A later disconnection or stream failure does not reverse a streaming charge.
</Warning>

## Next steps

* [Tools and pricing](/locus-pro/catalog): choose endpoints and inspect prices.
* [Node SDK](/locus-pro/sdk): read costs and handle errors in your application.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.