Skip to main content

objectiveai_sdk/auth/
request.rs

1//! Request types for authentication API endpoints.
2//!
3//! This module contains request structures for creating, disabling, and
4//! managing API keys, as well as configuring OpenRouter BYOK integration.
5
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9/// Request to create a new API key.
10///
11/// # Fields
12///
13/// * `expires` - Optional expiration timestamp. If `None`, the key never expires.
14/// * `name` - A user-provided name for identifying the key.
15/// * `description` - Optional description providing additional context.
16#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
17#[schemars(rename = "auth.CreateApiKeyRequest")]
18pub struct CreateApiKeyRequest {
19    /// The expiration timestamp for the API key, or `None` for a non-expiring key.
20    pub expires: Option<chrono::DateTime<chrono::Utc>>,
21    /// A user-provided name to identify this API key.
22    pub name: String,
23    /// An optional description providing additional context about the key's purpose.
24    pub description: Option<String>,
25}
26
27/// Request to disable an existing API key.
28///
29/// Once disabled, the API key can no longer be used for authentication.
30/// This action is reversible only by creating a new key.
31#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
32#[schemars(rename = "auth.DisableApiKeyRequest")]
33pub struct DisableApiKeyRequest {
34    /// The API key to disable.
35    pub api_key: super::ApiKey,
36}
37
38/// Request to create or update an OpenRouter BYOK (Bring Your Own Key) API key.
39///
40/// This allows users to provide their own OpenRouter API key for routing
41/// requests through OpenRouter's model marketplace.
42#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
43#[schemars(rename = "auth.CreateOpenRouterByokApiKeyRequest")]
44pub struct CreateOpenRouterByokApiKeyRequest {
45    /// The OpenRouter API key to associate with the user's account.
46    pub api_key: String,
47}