Skip to main content

ManagementClient

Struct ManagementClient 

Source
pub struct ManagementClient<'a> { /* private fields */ }
Expand description

Domain client for management endpoints.

Implementations§

Source§

impl<'a> ManagementClient<'a>

Source

pub async fn create_api_key( &self, name: &str, limit: Option<f64>, ) -> Result<ApiKey, OpenRouterError>

Create a managed API key (POST /keys).

Source

pub async fn create_api_key_in_workspace( &self, name: &str, limit: Option<f64>, workspace_id: Option<&str>, ) -> Result<ApiKey, OpenRouterError>

Create a managed API key in a workspace (POST /keys).

Source

pub async fn get_current_api_key_info( &self, ) -> Result<ApiKeyDetails, OpenRouterError>

Get current key session info (GET /key).

Source

pub async fn create_chat_completion_preset( &self, slug: &str, request: &ChatCompletionRequest, ) -> Result<PresetWithDesignatedVersion, OpenRouterError>

Create or update a preset from a chat-completions request body.

Source

pub async fn create_response_preset( &self, slug: &str, request: &ResponsesRequest, ) -> Result<PresetWithDesignatedVersion, OpenRouterError>

Create or update a preset from a Responses API request body.

Source

pub async fn create_message_preset( &self, slug: &str, request: &AnthropicMessagesRequest, ) -> Result<PresetWithDesignatedVersion, OpenRouterError>

Create or update a preset from an Anthropic-compatible Messages request body.

Source

pub async fn list_presets( &self, pagination: Option<PaginationOptions>, ) -> Result<ListPresetsResponse, OpenRouterError>

List presets (GET /presets).

Source

pub async fn get_preset( &self, slug: &str, ) -> Result<PresetWithDesignatedVersion, OpenRouterError>

Get one preset (GET /presets/{slug}).

Source

pub async fn list_preset_versions( &self, slug: &str, pagination: Option<PaginationOptions>, ) -> Result<ListPresetVersionsResponse, OpenRouterError>

List preset versions (GET /presets/{slug}/versions).

Source

pub async fn get_preset_version( &self, slug: &str, version: &str, ) -> Result<PresetDesignatedVersion, OpenRouterError>

Get a preset version (GET /presets/{slug}/versions/{version}).

Source

pub async fn delete_api_key(&self, hash: &str) -> Result<bool, OpenRouterError>

Delete an API key (DELETE /keys/{hash}).

Source

pub async fn update_api_key( &self, hash: &str, name: Option<String>, disabled: Option<bool>, limit: Option<f64>, ) -> Result<ApiKey, OpenRouterError>

Update an API key (PATCH /keys/{hash}).

Source

pub async fn list_api_keys( &self, pagination: Option<PaginationOptions>, include_disabled: Option<bool>, ) -> Result<Vec<ApiKey>, OpenRouterError>

List API keys (GET /keys).

Source

pub async fn list_api_keys_in_workspace( &self, pagination: Option<PaginationOptions>, include_disabled: Option<bool>, workspace_id: Option<&str>, ) -> Result<Vec<ApiKey>, OpenRouterError>

List API keys scoped to a workspace (GET /keys?workspace_id=...).

Source

pub async fn get_api_key(&self, hash: &str) -> Result<ApiKey, OpenRouterError>

Get an API key (GET /keys/{hash}).

Source

pub async fn create_auth_code( &self, request: &CreateAuthCodeRequest, ) -> Result<AuthCodeData, OpenRouterError>

Create OAuth auth code (POST /auth/keys/code).

Source

pub async fn create_api_key_from_auth_code( &self, code: &str, code_verifier: Option<&str>, code_challenge_method: Option<CodeChallengeMethod>, ) -> Result<AuthResponse, OpenRouterError>

Create an API key from auth code (POST /auth/keys).

Source

pub async fn create_coinbase_charge( &self, request: &CoinbaseChargeRequest, ) -> Result<CoinbaseChargeData, OpenRouterError>

Create a Coinbase charge (POST /credits/coinbase).

Source

pub async fn get_credits(&self) -> Result<CreditsData, OpenRouterError>

Get credits (GET /credits).

Source

pub async fn get_generation( &self, id: impl Into<String>, ) -> Result<GenerationData, OpenRouterError>

Get generation metadata (GET /generation?id=...).

Source

pub async fn get_generation_content( &self, id: impl Into<String>, ) -> Result<GenerationContentData, OpenRouterError>

Get stored generation content (GET /generation/content?id=...).

Source

pub async fn get_activity( &self, date: Option<&str>, ) -> Result<Vec<ActivityItem>, OpenRouterError>

Get endpoint usage activity (GET /activity).

Source

pub async fn get_analytics_meta(&self) -> Result<AnalyticsMeta, OpenRouterError>

Get analytics metadata (GET /analytics/meta).

Source

pub async fn query_analytics( &self, request: &AnalyticsQueryRequest, ) -> Result<AnalyticsQueryResponse, OpenRouterError>

Query analytics (POST /analytics/query).

Source

pub async fn list_byok_keys( &self, pagination: Option<PaginationOptions>, workspace_id: Option<&str>, provider: Option<&str>, ) -> Result<ByokKeyListResponse, OpenRouterError>

List BYOK provider credentials (GET /byok).

Source

pub async fn create_byok_key( &self, request: &CreateByokKeyRequest, ) -> Result<ByokKey, OpenRouterError>

Create a BYOK provider credential (POST /byok).

Source

pub async fn get_byok_key(&self, id: &str) -> Result<ByokKey, OpenRouterError>

Get a BYOK provider credential (GET /byok/{id}).

Source

pub async fn update_byok_key( &self, id: &str, request: &UpdateByokKeyRequest, ) -> Result<ByokKey, OpenRouterError>

Update a BYOK provider credential (PATCH /byok/{id}).

Source

pub async fn delete_byok_key(&self, id: &str) -> Result<bool, OpenRouterError>

Delete a BYOK provider credential (DELETE /byok/{id}).

Source

pub async fn list_observability_destinations( &self, pagination: Option<PaginationOptions>, workspace_id: Option<&str>, ) -> Result<ObservabilityDestinationListResponse, OpenRouterError>

List observability destinations (GET /observability/destinations).

Source

pub async fn create_observability_destination( &self, request: &CreateObservabilityDestinationRequest, ) -> Result<ObservabilityDestination, OpenRouterError>

Create an observability destination (POST /observability/destinations).

Source

pub async fn get_observability_destination( &self, id: &str, ) -> Result<ObservabilityDestination, OpenRouterError>

Get an observability destination (GET /observability/destinations/{id}).

Source

pub async fn update_observability_destination( &self, id: &str, request: &UpdateObservabilityDestinationRequest, ) -> Result<ObservabilityDestination, OpenRouterError>

Update an observability destination (PATCH /observability/destinations/{id}).

Source

pub async fn delete_observability_destination( &self, id: &str, ) -> Result<bool, OpenRouterError>

Delete an observability destination (DELETE /observability/destinations/{id}).

Source

pub async fn list_guardrails( &self, pagination: Option<PaginationOptions>, ) -> Result<GuardrailListResponse, OpenRouterError>

List guardrails (GET /guardrails).

Source

pub async fn list_guardrails_in_workspace( &self, pagination: Option<PaginationOptions>, workspace_id: Option<&str>, ) -> Result<GuardrailListResponse, OpenRouterError>

List guardrails scoped to a workspace (GET /guardrails?workspace_id=...).

Source

pub async fn create_guardrail( &self, request: &CreateGuardrailRequest, ) -> Result<Guardrail, OpenRouterError>

Create a guardrail (POST /guardrails).

Source

pub async fn get_guardrail( &self, id: &str, ) -> Result<Guardrail, OpenRouterError>

Get a guardrail (GET /guardrails/{id}).

Source

pub async fn update_guardrail( &self, id: &str, request: &UpdateGuardrailRequest, ) -> Result<Guardrail, OpenRouterError>

Update a guardrail (PATCH /guardrails/{id}).

Source

pub async fn delete_guardrail(&self, id: &str) -> Result<bool, OpenRouterError>

Delete a guardrail (DELETE /guardrails/{id}).

Source

pub async fn list_guardrail_key_assignments( &self, id: &str, pagination: Option<PaginationOptions>, ) -> Result<GuardrailKeyAssignmentsResponse, OpenRouterError>

List key assignments for a guardrail.

Source

pub async fn create_guardrail_key_assignments( &self, id: &str, request: &BulkKeyAssignmentRequest, ) -> Result<AssignedCountResponse, OpenRouterError>

Create key assignments for a guardrail.

Source

pub async fn delete_guardrail_key_assignments( &self, id: &str, request: &BulkKeyAssignmentRequest, ) -> Result<UnassignedCountResponse, OpenRouterError>

Delete key assignments from a guardrail.

Source

pub async fn list_guardrail_member_assignments( &self, id: &str, pagination: Option<PaginationOptions>, ) -> Result<GuardrailMemberAssignmentsResponse, OpenRouterError>

List member assignments for a guardrail.

Source

pub async fn create_guardrail_member_assignments( &self, id: &str, request: &BulkMemberAssignmentRequest, ) -> Result<AssignedCountResponse, OpenRouterError>

Create member assignments for a guardrail.

Source

pub async fn delete_guardrail_member_assignments( &self, id: &str, request: &BulkMemberAssignmentRequest, ) -> Result<UnassignedCountResponse, OpenRouterError>

Delete member assignments from a guardrail.

Source

pub async fn list_key_assignments( &self, pagination: Option<PaginationOptions>, ) -> Result<GuardrailKeyAssignmentsResponse, OpenRouterError>

List global key assignments.

Source

pub async fn list_member_assignments( &self, pagination: Option<PaginationOptions>, ) -> Result<GuardrailMemberAssignmentsResponse, OpenRouterError>

List global member assignments.

Source

pub async fn list_organization_members( &self, pagination: Option<PaginationOptions>, ) -> Result<OrganizationMembersResponse, OpenRouterError>

List organization members (GET /organization/members).

Source

pub async fn list_workspaces( &self, pagination: Option<PaginationOptions>, ) -> Result<WorkspaceListResponse, OpenRouterError>

List workspaces (GET /workspaces).

Source

pub async fn create_workspace( &self, request: &CreateWorkspaceRequest, ) -> Result<Workspace, OpenRouterError>

Create a workspace (POST /workspaces).

Source

pub async fn get_workspace( &self, id: &str, ) -> Result<Workspace, OpenRouterError>

Get a workspace (GET /workspaces/{id}).

Source

pub async fn update_workspace( &self, id: &str, request: &UpdateWorkspaceRequest, ) -> Result<Workspace, OpenRouterError>

Update a workspace (PATCH /workspaces/{id}).

Source

pub async fn update_workspace_with_cleared_io_logging_api_key_ids( &self, id: &str, request: &UpdateWorkspaceRequest, ) -> Result<Workspace, OpenRouterError>

Update a workspace and clear I/O logging API key filters (PATCH /workspaces/{id}).

Source

pub async fn delete_workspace(&self, id: &str) -> Result<bool, OpenRouterError>

Delete a workspace (DELETE /workspaces/{id}).

Source

pub async fn list_workspace_budgets( &self, id: &str, ) -> Result<ListWorkspaceBudgetsResponse, OpenRouterError>

List budgets for a workspace (GET /workspaces/{id}/budgets).

Source

pub async fn upsert_workspace_budget( &self, id: &str, interval: &str, request: &UpsertWorkspaceBudgetRequest, ) -> Result<WorkspaceBudget, OpenRouterError>

Create or update a workspace budget (PUT /workspaces/{id}/budgets/{interval}).

Source

pub async fn delete_workspace_budget( &self, id: &str, interval: &str, ) -> Result<bool, OpenRouterError>

Delete a workspace budget (DELETE /workspaces/{id}/budgets/{interval}).

Source

pub async fn add_workspace_members( &self, id: &str, request: &WorkspaceMembersRequest, ) -> Result<WorkspaceMembersAddResponse, OpenRouterError>

Add workspace members (POST /workspaces/{id}/members/add).

Source

pub async fn remove_workspace_members( &self, id: &str, request: &WorkspaceMembersRequest, ) -> Result<WorkspaceMembersRemoveResponse, OpenRouterError>

Remove workspace members (POST /workspaces/{id}/members/remove).

Trait Implementations§

Source§

impl<'a> Clone for ManagementClient<'a>

Source§

fn clone(&self) -> ManagementClient<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ManagementClient<'a>

Source§

impl<'a> Debug for ManagementClient<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ManagementClient<'a>

§

impl<'a> !UnwindSafe for ManagementClient<'a>

§

impl<'a> Freeze for ManagementClient<'a>

§

impl<'a> Send for ManagementClient<'a>

§

impl<'a> Sync for ManagementClient<'a>

§

impl<'a> Unpin for ManagementClient<'a>

§

impl<'a> UnsafeUnpin for ManagementClient<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more