Skip to main content

OpenCodeZenClient

Struct OpenCodeZenClient 

Source
pub struct OpenCodeZenClient { /* private fields */ }
Expand description

Concrete OpenCode Zen API client.

Implementations§

Source§

impl OpenCodeZenClient

Source

pub fn from_env_or_dotenv(workspace_root: &Path) -> Result<Self>

Create a client from OPENCODE_ZEN_KEY, falling back to managed stores and workspace .env.

Source

pub fn new(base_url: &str, api_key: &str) -> Self

Create a client with an explicit base URL and API key.

Source

pub fn fetch_models(&self) -> Result<Vec<ModelInfo>>

Fetch model metadata from GET /models.

Source

pub fn build_chat_headers(&self) -> Vec<(String, String)>

Build the headers for a chat-completions request.

Source

pub fn build_messages_headers(&self) -> Vec<(String, String)>

Build headers for an Anthropic-compatible Messages request.

Source

pub fn build_chat_request_body( model: &str, messages: &[ProviderMessage], max_tokens: u32, stream: bool, tools: Option<&Value>, ) -> Result<Value>

Build a request body for POST /chat/completions.

Source

pub fn build_request_body( model: &str, messages: &[ProviderMessage], max_tokens: u32, tools: Option<&Value>, effort: ReasoningEffort, summary: ReasoningSummary, continuation: &ProviderContinuation, ) -> Result<Value>

Build the request body for the endpoint family selected by model.

Source

pub fn send_streaming_request( &self, model: &str, messages: &[ProviderMessage], max_tokens: u32, tools: Option<&Value>, effort: ReasoningEffort, summary: ReasoningSummary, continuation: &ProviderContinuation, ) -> Result<Response<Body>>

Send a streaming request to the endpoint selected by model.

Trait Implementations§

Source§

impl StreamingProvider for OpenCodeZenClient

Source§

type Metadata = Vec<ModelInfo>

Source§

fn name(&self) -> &'static str

Source§

fn load_status(&self) -> String

Source§

fn request_status(&self, model: &str) -> String

Source§

fn from_env_or_dotenv(root: &Path) -> Result<Self>

Source§

fn load_metadata(&self) -> Result<Self::Metadata>

Source§

fn metadata_loaded_event(&self, metadata: &Self::Metadata) -> Option<AgentEvent>

Source§

fn metadata_status( &self, model: &str, metadata: &Self::Metadata, ) -> Option<String>

Source§

fn token_budget(&self, _model: &str, _metadata: Option<&Self::Metadata>) -> u32

Source§

fn serialized_request_body( &self, model: &str, messages: &[ProviderMessage], request: &StreamingRequest<'_>, ) -> Result<Vec<u8>>

Serialize exactly the request body that the adapter sends.
Source§

fn send_streaming_request( &self, model: &str, messages: &[ProviderMessage], request: &StreamingRequest<'_>, ) -> Result<Response<Body>>

Source§

fn stream_format(&self, model: &str) -> Result<StreamFormat>

Source§

fn request_error_message(error: &ProviderError) -> String

Source§

fn is_retryable_request_error(error: &ProviderError) -> bool

Auto Trait Implementations§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoMaybeUndefined<T> for T

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
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> Same for T

Source§

type Output = T

Should always be Self
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