Skip to main content
The SDK is not limited to the vendors it ships with. Every built-in vendor is supported through a recipe: a small, plain-data description of which client methods make model calls, and where the response says how much they used. The same interface is open to you, so you can meter and gate any client:
  • A vendor the SDK does not support yet.
  • Your own models, or an internal AI service with its own client.
  • A client you got from somewhere else, such as an open-source library.
Write a recipe and pass it to wrap(). Everything else, checking before each call and reporting after it, works exactly as it does for the built-in vendors.

Write a recipe

You can also start from a built-in recipe and change part of it, for example to add an estimate to every method of anthropicRecipe. See Requested usage for an example.

Use it

Pass the recipe to wrap(), then call the client as usual:
Make one call, then open the customer in the Stigg app and check that a usage event arrived with the metrics you expect.

Contribute your recipe

The Agent SDK is open source, and the built-in recipes are written exactly the way yours is. If you wrote a recipe for a vendor other developers use too, contribute it to the Agent SDK on GitHub. Once it is merged, the SDK recognizes that vendor automatically and no one needs to pass a recipe for it.

Usage without a client

Wrapping works when you call a model through a client object. Sometimes there is nothing to wrap: for example, you call a model over plain HTTP, or the usage is not a model call at all, such as a paid web-search API your agent uses. In that case, count the usage yourself and send it to Stigg with stigg.report():
The keys are the IDs of the Stigg features or credit currencies to report against. To check before the call, use stigg.check(). For a full example, see Gating actions that are not model calls. Need a vendor we do not support yet? Let us know.