Skip to content
Draft
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
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
Loading