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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/temps-ai-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ tower = { workspace = true }
http-body-util = { workspace = true }
http = { workspace = true }
hyper = { workspace = true }
temps-database = { path = "../temps-database" }
42 changes: 42 additions & 0 deletions crates/temps-ai-gateway/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,48 @@ pub enum AiGatewayError {
#[error("Model '{model}' is not allowed in scope '{scope}'")]
ModelNotAllowed { model: String, scope: String },

#[error(
"AI gateway rate limit exceeded for scope '{scope}': maximum {limit_per_minute} requests per minute; retry in {retry_after_seconds}s"
)]
RateLimitExceeded {
scope: String,
limit_per_minute: i64,
retry_after_seconds: u64,
},

#[error(
"AI gateway monthly budget exceeded for scope '{scope}': spent {spent_microcents} of {limit_microcents} microcents"
)]
MonthlyBudgetExceeded {
scope: String,
spent_microcents: i64,
limit_microcents: i64,
},

#[error("No pricing is configured for model '{model}' required by budget scope '{scope}'")]
PricingUnavailable { model: String, scope: String },

#[error(
"AI gateway budget scope '{scope}' requires max_tokens so spend can be reserved safely"
)]
BudgetRequiresMaxTokens { scope: String },

#[error("AI gateway budget scope '{scope}' cannot safely project remote image token cost")]
BudgetProjectionUnavailable { scope: String },

#[error("Invalid AI gateway governance config for scope '{scope}': {field}={value} must be non-negative")]
InvalidGovernanceConfig {
scope: String,
field: &'static str,
value: i64,
},

#[error("Invalid AI gateway governance scope '{scope}'; expected instance, project:<id>, environment:<id>, or token:<id>")]
InvalidGovernanceScope { scope: String },

#[error("AI gateway governance config for scope '{scope}' was not found")]
GovernanceConfigNotFound { scope: String },

#[error("Upstream provider error for model '{model}': {status} {message}")]
UpstreamError {
model: String,
Expand Down
Loading
Loading