Skip to main content
Ollama runs open models on your own hardware. No vendor bills you per token, so with Ollama you meter and limit the use of your own capacity, for example to give each customer or agent a share of it.

Set up

Wrap an instance of Ollama from the ollama package. The SDK recognizes it automatically.
Both chat and generate are covered.

With the OpenAI client

Ollama also serves an API in OpenAI’s format. To call it with an OpenAI client, point the baseURL at Ollama and wrap it:
Ollama does not check the API key, but the OpenAI client requires one, so pass any string. Calls through the OpenAI client are metered with the OpenAI recipe: they are reported under the openai.chat.completions.create and openai.responses.create event names, with the same metrics as OpenAI. See Ollama’s OpenAI compatibility docs.

What is reported

The responses of Ollama’s own API include the number of tokens each call processed. The wrapper reads them and reports them to Stigg as the metrics below. For details, see Ollama’s API docs. total_tokens includes the other two, so price the total or the parts, never both. Other Ollama methods are not metered: embed measures a different kind of usage, and pull, push and create manage models rather than run them. Ollama’s webSearch and webFetch are billed by ollama.com but return no token counts, so they are not metered either.