# Replace llm pricing rules

URL: https://docs.hanzo.ai/docs/openapi/o11y/createorupdatellmpricingrules

> Writes the pricing-rule batch — the single write endpoint used by both the user and the Zeus sync job.

`PUT /v1/o11y/llm_pricing_rules`

> [O11y →](https://docs.hanzo.ai/docs/openapi/o11y) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                  |
| ------------- | ------------------------------------------------ |
| **Address**   | `https://api.hanzo.ai/v1/o11y/llm_pricing_rules` |
| **Method**    | `PUT`                                            |
| **Operation** | `CreateOrUpdateLLMPricingRules`                  |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`           |

Writes the pricing-rule batch — the single write
endpoint used by both the user and the Zeus sync job. Per-rule match is by id,
then sourceId, then insert; an override row is fully preserved when the
request omits isOverride, only its synced\_at stamped.

Callers need the admin role; the runtime's own gate enforces it.

## Request

16 fields, body `application/json` (required).

| Field                         | In   | Type                                | Required | Description                                                                                                                                        |
| ----------------------------- | ---- | ----------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rules`                       | body | o11y.O11yLLMUpdatablePricingRule\[] | —        | Rules are the rules to create or update, matched per rule.                                                                                         |
| `rules[].enabled`             | body | boolean                             | —        | Enabled turns the rule on.                                                                                                                         |
| `rules[].id`                  | body | string                              | —        | ID matches an existing rule by its id.                                                                                                             |
| `rules[].isOverride`          | body | boolean                             | —        | IsOverride pins the rule so the sync job skips it.                                                                                                 |
| `rules[].modelName`           | body | string                              | —        | Model is the model the rule prices.                                                                                                                |
| `rules[].modelPattern`        | body | string\[]                           | —        | ModelPattern are the model-name globs the rule matches.                                                                                            |
| `rules[].pricing`             | body | o11y.O11yLLMRulePricing             | —        |                                                                                                                                                    |
| `rules[].pricing.cache`       | body | o11y.O11yLLMPricingCacheCosts       | —        |                                                                                                                                                    |
| `rules[].pricing.cache.mode`  | body | string                              | —        | Mode is how cached tokens are counted — subtract (inside input\_tokens, OpenAI-style), additive (reported separately, Anthropic-style) or unknown. |
| `rules[].pricing.cache.read`  | body | number (double)                     | —        | Read is the cost per unit of cache-read tokens.                                                                                                    |
| `rules[].pricing.cache.write` | body | number (double)                     | —        | Write is the cost per unit of cache-write tokens.                                                                                                  |
| `rules[].pricing.input`       | body | number (double)                     | —        | Input is the cost per unit of input tokens.                                                                                                        |
| `rules[].pricing.output`      | body | number (double)                     | —        | Output is the cost per unit of output tokens.                                                                                                      |
| `rules[].provider`            | body | string                              | —        | Provider is the model's provider.                                                                                                                  |
| `rules[].sourceId`            | body | string                              | —        | SourceID matches an existing rule by its upstream source id.                                                                                       |
| `rules[].unit`                | body | string                              | —        | Unit is the pricing unit, e.g. per\_million\_tokens.                                                                                               |

## Response

| Status    | Body            | Meaning           |
| --------- | --------------- | ----------------- |
| `202`     | Approval        | held for approval |
| `204`     | —               | no content        |
| `default` | problem-details | refused           |

`202` body — 3 fields.

| Field    | In   | Type   | Always | Description |
| -------- | ---- | ------ | ------ | ----------- |
| `clause` | body | string | —      |             |
| `reason` | body | string | —      |             |
| `status` | body | string | —      |             |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo o11y llm_pricing_rules replace
```

**SDK**

**.ts**

```ts
import { Configuration, O11yApi } from 'hanzoai';

const api = new O11yApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.createOrUpdateLLMPricingRules({ rules: [{"enabled":false,"id":"<id>","isOverride":false,"modelName":"<modelName>"}] });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import O11yApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = O11yApi(client).create_or_update_llm_pricing_rules(rules=[{"enabled":false,"id":"<id>","isOverride":false,"modelName":"<modelName>"}])
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.O11yAPI.CreateOrUpdateLLMPricingRules(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, o11y_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = o11y_api::create_or_update_llm_pricing_rules(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.O11yApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new O11yApi(client).createOrUpdateLLMPricingRules();
```

**HTTP**

```bash
curl -X PUT https://api.hanzo.ai/v1/o11y/llm_pricing_rules \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "rules": [
         {
           "enabled": false,
           "id": "<id>",
           "isOverride": false,
           "modelName": "<modelName>"
         }
       ]
     }'
```

**MCP**

Tool `o11y`, op `CreateOrUpdateLLMPricingRules` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "o11y",
         "arguments": {
           "op": "CreateOrUpdateLLMPricingRules",
           "input": {
             "rules": [
               {
                 "enabled": false,
                 "id": "<id>",
                 "isOverride": false,
                 "modelName": "<modelName>"
               }
             ]
           }
         }
       }
     }'
```

---

[O11y API](https://docs.hanzo.ai/docs/openapi/o11y) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
