Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
version: v2
deps:
- name: buf.build/aep/api
commit: 5f3e69139afa4fd08d15ad22b69721dc
digest: b5:e98a18cb282e37c024506b371a2c3be5da23209458b44ed4010b562d1d31da6fdfb203d74e3b20d12e0f72a13ed9a195a188c0db3ae05bf02c4dc4cdbd120fc1
commit: 26a011a354ee4836847fff32738f12a2
digest: b5:5f32f8d8d0eaafd808d9162b0a1c1d2d3e6ed3710d20973a036788727c2a54ce2771f198a053132aa892f5986690995093c0b7538b879fc1c0c9dee4d05ac156
- name: buf.build/bufbuild/protovalidate
commit: 52f32327d4b045a79293a6ad4e7e1236
digest: b5:cbabc98d4b7b7b0447c9b15f68eeb8a7a44ef8516cb386ac5f66e7fd4062cd6723ed3f452ad8c384b851f79e33d26e7f8a94e2b807282b3def1cd966c7eace97
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ message TokenUsage {

// The number of cache read tokens.
int64 cache_read_tokens = 4;

// The total number of credits used.
int64 total_credits = 5;
}

// ContentBlockType denotes the available content block types.
Expand Down
151 changes: 151 additions & 0 deletions proto/tim-api/tim/api/pricing/v1alpha1/pricing_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
syntax = "proto3";

package tim.api.pricing.v1alpha1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "tim/api/pricing/v1alpha1/pricing_types.proto";

// PricingService provides operations for managing LLM model pricing
service PricingService {
option (google.api.default_host) = "tim-api.settlerlabs.com";

// Get pricing for a specific model
rpc GetModelPricing(GetModelPricingRequest) returns (ModelPricing) {
option (google.api.http) = {get: "/v1alpha1/{name=modelPricing/*}"};
option (google.api.method_signature) = "name";
}

// List all model pricing
rpc ListModelPricing(ListModelPricingRequest) returns (ListModelPricingResponse) {
option (google.api.http) = {get: "/v1alpha1/modelPricing"};
}

// Create new model pricing
rpc CreateModelPricing(CreateModelPricingRequest) returns (ModelPricing) {
option (google.api.http) = {
post: "/v1alpha1/modelPricing"
body: "model_pricing"
};
option (google.api.method_signature) = "model_pricing";
}

// Update existing model pricing
rpc UpdateModelPricing(UpdateModelPricingRequest) returns (ModelPricing) {
option (google.api.http) = {
patch: "/v1alpha1/{model_pricing.path=modelPricing/*}"
body: "model_pricing"
};
option (google.api.method_signature) = "model_pricing";
}

// Delete model pricing
rpc DeleteModelPricing(DeleteModelPricingRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/v1alpha1/{name=modelPricing/*}"};
option (google.api.method_signature) = "name";
}

// Get pricing by provider
rpc GetPricingByProvider(GetPricingByProviderRequest) returns (GetPricingByProviderResponse) {
option (google.api.http) = {get: "/v1alpha1/modelPricing:byProvider"};
option (google.api.method_signature) = "provider_name";
}
}

// Request message for GetModelPricing
message GetModelPricingRequest {
// The resource name of the model pricing to retrieve
string name = 1 [
(google.api.resource_reference) = {type: "tim.settlerlabs.com/model-pricing"},
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^modelPricing/.+$"
];
}

// Request message for ListModelPricing
message ListModelPricingRequest {
// The maximum number of items to return
int32 page_size = 1 [(buf.validate.field).int32 = {
gte: 1
lte: 1000
}];

// The next_page_token value returned from a previous request, if any
string page_token = 2;

// Filter by provider name (optional)
string filter_provider = 3 [(buf.validate.field).string.max_len = 100];
}

// Response message for ListModelPricing
message ListModelPricingResponse {
// The list of model pricing
repeated ModelPricing model_pricing = 1;

// Token to retrieve the next page of results, or empty if there are no more results
string next_page_token = 2;

// Total number of items available
int32 total_size = 3;
}

// Request message for CreateModelPricing
message CreateModelPricingRequest {
// The model pricing to create
ModelPricing model_pricing = 1 [(buf.validate.field).required = true];
}

// Request message for UpdateModelPricing
message UpdateModelPricingRequest {
// The model pricing to update
ModelPricing model_pricing = 1 [(buf.validate.field).required = true];

// The list of fields to update
google.protobuf.FieldMask update_mask = 2;
}

// Request message for DeleteModelPricing
message DeleteModelPricingRequest {
// The resource name of the model pricing to delete
string name = 1 [
(google.api.resource_reference) = {type: "tim.settlerlabs.com/model-pricing"},
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^modelPricing/.+$"
];
}

// Request message for GetPricingByProvider
message GetPricingByProviderRequest {
// The provider name to filter by
string provider_name = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 100
];

// The maximum number of items to return
int32 page_size = 2 [(buf.validate.field).int32 = {
gte: 1
lte: 1000
}];

// The next_page_token value returned from a previous request, if any
string page_token = 3;
}

// Response message for GetPricingByProvider
message GetPricingByProviderResponse {
// The list of model pricing for the provider
repeated ModelPricing model_pricing = 1;

// Token to retrieve the next page of results, or empty if there are no more results
string next_page_token = 2;

// Total number of items available for this provider
int32 total_size = 3;
}
82 changes: 82 additions & 0 deletions proto/tim-api/tim/api/pricing/v1alpha1/pricing_types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
syntax = "proto3";

package tim.api.pricing.v1alpha1;

import "buf/validate/validate.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

// ModelPricing represents the pricing information for an LLM model
message ModelPricing {
option (google.api.resource) = {
type: "tim.settlerlabs.com/model-pricing"
pattern: ["modelPricing/{model}"]
plural: "model-pricing"
singular: "model-pricing"
};

// The resource path identifier (model ID)
string path = 1 [
(google.api.field_behavior) = OUTPUT_ONLY,
(buf.validate.field).string.min_len = 1,
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];

// Unique identifier for the model
string model_id = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 255
];

// Name of the LLM provider (e.g., "anthropic", "openai", "google")
string provider_name = 3 [
(buf.validate.field).required = true,
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.max_len = 100
];

// Price per 1 million input tokens
string input_price_per_1m_tokens = 4 [
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^[0-9]+(\\.[0-9]{1,4})?$"
];

// Price per 1 million output tokens
string output_price_per_1m_tokens = 5 [
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^[0-9]+(\\.[0-9]{1,4})?$"
];

// Price per 1 million cached input tokens (optional)
optional string cached_input_price_per_1m_tokens = 6 [
(buf.validate.field).string.pattern = "^[0-9]+(\\.[0-9]{1,4})?$",
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];

// Price per 1 million cached output tokens (optional)
optional string cached_output_price_per_1m_tokens = 7 [
(buf.validate.field).string.pattern = "^[0-9]+(\\.[0-9]{1,4})?$",
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];

// Currency code (ISO 4217)
string currency = 8 [
(buf.validate.field).required = true,
(buf.validate.field).string.len = 3,
(buf.validate.field).string.pattern = "^[A-Z]{3}$"
];

// Timestamp when the pricing was created
google.protobuf.Timestamp create_time = 9 [
(buf.validate.field).required = true,
(google.api.field_behavior) = OUTPUT_ONLY
];

// Timestamp when the pricing was last updated
google.protobuf.Timestamp update_time = 10 [
(buf.validate.field).required = true,
(google.api.field_behavior) = OUTPUT_ONLY
];
}
12 changes: 12 additions & 0 deletions tim-db/gen/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading