Model Costs
Overview
The Confident AI SDK exposes every Model Cost method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.
Methods
List Model Costs
Lists the custom model prices your Confident AI project uses one page at a time, newest first. When the project inherits its pricing from the organization the response carries the organization's model costs and inherit is true, in which case they can only be changed from the organization's own project.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.model_costs.list(page=1, page_size=25, search_term="gpt-4o")For async mode, call a_list and await it as shown below:
result = await client.model_costs.a_list(...)Parameters
| Parameter | Type | Description |
|---|---|---|
page | Optional[int] | The page to return. Defaults to 1. |
page_size | Optional[int] | The number of model costs per page, at most 100. Defaults to 25. |
search_term | Optional[str] | Returns only model costs whose match pattern or provider contains this text, case-insensitively. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.modelCosts.list(
{ page: 1, pageSize: 25, searchTerm: "gpt-4o" },
);Parameters
| Parameter | Type | Description |
|---|---|---|
page | number | The page to return. Defaults to 1. |
pageSize | number | The number of model costs per page, at most 100. Defaults to 25. |
searchTerm | string | Returns only model costs whose match pattern or provider contains this text, case-insensitively. |
Returns
This method returns an object of type ModelCostList.
Create Model Cost
Adds a custom model price to your Confident AI project and returns its id. Confident AI applies it to an LLM span whose model name matches matchPattern and whose provider did not report a priceable cost. This fails while the project inherits its model costs from the organization.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.model_costs.create(
match_pattern="^gpt-4o",
provider="openai",
input_cost_per_million_tokens=2.5,
output_cost_per_million_tokens=10,
)For async mode, call a_create and await it as shown below:
result = await client.model_costs.a_create(...)Parameters
| Parameter | Type | Description |
|---|---|---|
match_pattern | str | Required. The case-insensitive regular expression a model name must match for this cost to apply. |
provider | Optional[str] | The model provider this cost applies to, matched case- insensitively against the provider recorded on the LLM span. Send null or omit it for a cost that applies whatever the provider, which is only used when no provider-specific cost matches. |
input_cost_per_million_tokens | Optional[float] | The cost in USD of one million input tokens. Send null when only the output rate is priced; input tokens are then costed at zero. |
output_cost_per_million_tokens | Optional[float] | The cost in USD of one million output tokens. Send null when only the input rate is priced; output tokens are then costed at zero. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.modelCosts.create(
"^gpt-4o",
{
provider: "openai",
inputCostPerMillionTokens: 2.5,
outputCostPerMillionTokens: 10
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
matchPattern | string | Required. The case-insensitive regular expression a model name must match for this cost to apply. |
provider | string | null | The model provider this cost applies to, matched case- insensitively against the provider recorded on the LLM span. Send null or omit it for a cost that applies whatever the provider, which is only used when no provider-specific cost matches. |
inputCostPerMillionTokens | number | null | The cost in USD of one million input tokens. Send null when only the output rate is priced; input tokens are then costed at zero. |
outputCostPerMillionTokens | number | null | The cost in USD of one million output tokens. Send null when only the input rate is priced; output tokens are then costed at zero. |
Returns
This method returns an object of type ModelCostRef.
Update Model Cost
Replaces a custom model price and returns it. The body is the model cost as it should read afterwards, so a field you omit is cleared rather than left alone. This fails while the project inherits its model costs from the organization.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.model_costs.update(
model_cost_id="<MODEL-COST-ID>",
match_pattern="^gpt-4o",
provider="openai",
input_cost_per_million_tokens=2.5,
output_cost_per_million_tokens=10,
)For async mode, call a_update and await it as shown below:
result = await client.model_costs.a_update(...)Parameters
| Parameter | Type | Description |
|---|---|---|
model_cost_id | str | Required. The id of the model cost. |
match_pattern | str | Required. The case-insensitive regular expression a model name must match for this cost to apply. |
provider | Optional[str] | The model provider this cost applies to, matched case- insensitively against the provider recorded on the LLM span. Send null or omit it for a cost that applies whatever the provider, which is only used when no provider-specific cost matches. |
input_cost_per_million_tokens | Optional[float] | The cost in USD of one million input tokens. Send null when only the output rate is priced; input tokens are then costed at zero. |
output_cost_per_million_tokens | Optional[float] | The cost in USD of one million output tokens. Send null when only the input rate is priced; output tokens are then costed at zero. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.modelCosts.update(
"<MODEL-COST-ID>",
"^gpt-4o",
{
provider: "openai",
inputCostPerMillionTokens: 2.5,
outputCostPerMillionTokens: 10
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
modelCostId | string | Required. The id of the model cost. |
matchPattern | string | Required. The case-insensitive regular expression a model name must match for this cost to apply. |
provider | string | null | The model provider this cost applies to, matched case- insensitively against the provider recorded on the LLM span. Send null or omit it for a cost that applies whatever the provider, which is only used when no provider-specific cost matches. |
inputCostPerMillionTokens | number | null | The cost in USD of one million input tokens. Send null when only the output rate is priced; input tokens are then costed at zero. |
outputCostPerMillionTokens | number | null | The cost in USD of one million output tokens. Send null when only the input rate is priced; output tokens are then costed at zero. |
Returns
This method returns an object of type ModelCost.
Delete Model Cost
Permanently deletes a custom model price. Models it matched fall back to Confident AI's own pricing, and costs already recorded on past spans are unchanged. This fails while the project inherits its model costs from the organization.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.model_costs.delete(model_cost_id="<MODEL-COST-ID>")For async mode, call a_delete and await it as shown below:
result = await client.model_costs.a_delete(...)Parameters
| Parameter | Type | Description |
|---|---|---|
model_cost_id | str | Required. The id of the model cost. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.modelCosts.delete("<MODEL-COST-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
modelCostId | string | Required. The id of the model cost. |
Returns
This method returns an object of type ModelCostRef.
Types
ModelCost
A custom price for the models whose names match matchPattern. Confident AI uses it to cost an LLM span whose provider did not report a priceable cost, taking a provider-specific match first and a provider-less one otherwise.
class ModelCost:
id: str
match_pattern: str = Field(alias="matchPattern")
provider: Optional[str]
input_cost_per_million_tokens: Optional[float] = Field(alias="inputCostPerMillionTokens")
output_cost_per_million_tokens: Optional[float] = Field(alias="outputCostPerMillionTokens")
created_at: str = Field(alias="createdAt")
updated_at: str = Field(alias="updatedAt")idstrRequired
The id of the model cost, generated by Confident AI.
Example: "<MODEL-COST-ID>"
match_patternstrRequired
The case-insensitive regular expression a model name must match for this cost to apply.
Example: "^gpt-4o"
providerOptional[str]Required
The model provider this cost applies to, or null when it applies whatever the provider.
Example: "openai"
input_cost_per_million_tokensOptional[float]Required
The cost in USD of one million input tokens, or null when the input rate is not priced.
Example: 2.5
output_cost_per_million_tokensOptional[float]Required
The cost in USD of one million output tokens, or null when the output rate is not priced.
Example: 10
created_atstrRequired
The timestamp when the model cost was created.
Example: "2025-01-15T10:30:00+00:00"
updated_atstrRequired
The timestamp when the model cost was last updated.
Example: "2025-01-16T09:05:00+00:00"
interface ModelCost {
id: string;
matchPattern: string;
provider: string | null;
inputCostPerMillionTokens: number | null;
outputCostPerMillionTokens: number | null;
createdAt: string;
updatedAt: string;
}idstringRequired
The id of the model cost, generated by Confident AI.
Example: "<MODEL-COST-ID>"
matchPatternstringRequired
The case-insensitive regular expression a model name must match for this cost to apply.
Example: "^gpt-4o"
providerstring | nullRequired
The model provider this cost applies to, or null when it applies whatever the provider.
Example: "openai"
inputCostPerMillionTokensnumber | nullRequired
The cost in USD of one million input tokens, or null when the input rate is not priced.
Example: 2.5
outputCostPerMillionTokensnumber | nullRequired
The cost in USD of one million output tokens, or null when the output rate is not priced.
Example: 10
createdAtstringRequired
The timestamp when the model cost was created.
Example: "2025-01-15T10:30:00+00:00"
updatedAtstringRequired
The timestamp when the model cost was last updated.
Example: "2025-01-16T09:05:00+00:00"
ModelCostList
One page of model costs, with the total across all pages.
class ModelCostList:
model_costs: List[ModelCost] = Field(alias="modelCosts")
total_model_costs: int = Field(alias="totalModelCosts")
inherit: bool
page: int
page_size: int = Field(alias="pageSize")model_costsList[ModelCost]Required
The model costs for the current page, newest first.
See ModelCost.
total_model_costsintRequired
The total number of model costs this project resolves.
Example: 4
inheritboolRequired
Whether these model costs come from the organization rather than the project. When true they are read-only through the API, and creating, updating or deleting one fails until 'Inherit Custom Model Pricing From Organization' is turned off in the project's model costs settings.
Example: false
pageintRequired
The page this response covers.
Example: 1
page_sizeintRequired
The number of model costs per page.
Example: 25
interface ModelCostList {
modelCosts: ModelCost[];
totalModelCosts: number;
inherit: boolean;
page: number;
pageSize: number;
}modelCostsModelCost[]Required
The model costs for the current page, newest first.
See ModelCost.
totalModelCostsnumberRequired
The total number of model costs this project resolves.
Example: 4
inheritbooleanRequired
Whether these model costs come from the organization rather than the project. When true they are read-only through the API, and creating, updating or deleting one fails until 'Inherit Custom Model Pricing From Organization' is turned off in the project's model costs settings.
Example: false
pagenumberRequired
The page this response covers.
Example: 1
pageSizenumberRequired
The number of model costs per page.
Example: 25
ModelCostRef
A reference to a model cost by its id.
class ModelCostRef:
id: stridstrRequired
The id of the model cost, generated by Confident AI.
Example: "<MODEL-COST-ID>"
interface ModelCostRef {
id: string;
}idstringRequired
The id of the model cost, generated by Confident AI.
Example: "<MODEL-COST-ID>"
Last updated on