pub struct OpenCodeGoClient { /* private fields */ }Expand description
Concrete OpenCode Go API client.
Implementations§
Source§impl OpenCodeGoClient
impl OpenCodeGoClient
Sourcepub fn from_env_or_dotenv(workspace_root: &Path) -> Result<Self>
pub fn from_env_or_dotenv(workspace_root: &Path) -> Result<Self>
Create a client from OPENCODE_GO_KEY, falling back to workspace .env.
Sourcepub fn new(base_url: &str, api_key: &str) -> Self
pub fn new(base_url: &str, api_key: &str) -> Self
Create a client with an explicit base URL and API key.
Sourcepub fn fetch_models(&self) -> Result<Vec<ModelInfo>>
pub fn fetch_models(&self) -> Result<Vec<ModelInfo>>
Fetch model metadata from GET /models.
Sourcepub fn build_chat_headers(&self) -> Vec<(String, String)>
pub fn build_chat_headers(&self) -> Vec<(String, String)>
Build the headers for an OpenAI-compatible chat-completions request.
Sourcepub fn build_messages_headers(&self) -> Vec<(String, String)>
pub fn build_messages_headers(&self) -> Vec<(String, String)>
Build the headers for an Anthropic-compatible messages request.
Sourcepub fn build_chat_request_body(
model: &str,
messages: &[ProviderMessage],
max_tokens: u32,
stream: bool,
tools: Option<&Value>,
) -> Result<Value>
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.
Sourcepub fn build_messages_request_body(
model: &str,
messages: &[ProviderMessage],
max_tokens: u32,
stream: bool,
tools: Option<&Value>,
) -> Result<Value>
pub fn build_messages_request_body( model: &str, messages: &[ProviderMessage], max_tokens: u32, stream: bool, tools: Option<&Value>, ) -> Result<Value>
Build a request body for POST /messages.
Sourcepub fn send_streaming_request(
&self,
model: &str,
messages: &[ProviderMessage],
max_tokens: u32,
tools: Option<&Value>,
) -> Result<Response<Body>>
pub fn send_streaming_request( &self, model: &str, messages: &[ProviderMessage], max_tokens: u32, tools: Option<&Value>, ) -> Result<Response<Body>>
Send a streaming request to the route selected by model.
Trait Implementations§
Source§impl StreamingProvider for OpenCodeGoClient
impl StreamingProvider for OpenCodeGoClient
Source§fn send_streaming_request(
&self,
model: &str,
messages: &[ProviderMessage],
request: &StreamingRequest<'_>,
) -> Result<Response<Body>>
fn send_streaming_request( &self, model: &str, messages: &[ProviderMessage], request: &StreamingRequest<'_>, ) -> Result<Response<Body>>
TODO: Map reasoning effort and summaries when the OpenCode Go backend exposes model-specific controls for them.
type Metadata = Vec<ModelInfo>
fn name(&self) -> &'static str
fn load_status(&self) -> String
fn request_status(&self, model: &str) -> String
fn from_env_or_dotenv(root: &Path) -> Result<Self>
fn load_metadata(&self) -> Result<Self::Metadata>
fn metadata_loaded_event(&self, metadata: &Self::Metadata) -> Option<AgentEvent>
fn metadata_status( &self, model: &str, metadata: &Self::Metadata, ) -> Option<String>
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>>
fn serialized_request_body( &self, model: &str, messages: &[ProviderMessage], request: &StreamingRequest<'_>, ) -> Result<Vec<u8>>
Serialize exactly the request body that the adapter sends.
fn stream_format(&self, model: &str) -> Result<StreamFormat>
fn request_error_message(error: &ProviderError) -> String
fn is_retryable_request_error(error: &ProviderError) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for OpenCodeGoClient
impl !UnwindSafe for OpenCodeGoClient
impl Freeze for OpenCodeGoClient
impl Send for OpenCodeGoClient
impl Sync for OpenCodeGoClient
impl Unpin for OpenCodeGoClient
impl UnsafeUnpin for OpenCodeGoClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.