pub struct VsCodeCopilotClient { /* private fields */ }Expand description
HTTP client for GitHub Copilot API.
Supports both direct API access and proxy mode.
Implementations§
Source§impl VsCodeCopilotClient
impl VsCodeCopilotClient
Sourcepub fn new(timeout: Duration) -> Result<Self>
pub fn new(timeout: Duration) -> Result<Self>
Create a new client with direct API mode (default).
Uses api.githubcopilot.com directly without a proxy.
Sourcepub fn with_base_url(
base_url: impl Into<String>,
timeout: Duration,
) -> Result<Self>
pub fn with_base_url( base_url: impl Into<String>, timeout: Duration, ) -> Result<Self>
Create a new client with a custom base URL (for proxy mode).
This is the legacy mode that connects to a local copilot-api proxy.
Sourcepub fn new_with_options(
timeout: Duration,
direct_mode: bool,
account_type: AccountType,
) -> Result<Self>
pub fn new_with_options( timeout: Duration, direct_mode: bool, account_type: AccountType, ) -> Result<Self>
Create a new client with specified options.
§Arguments
timeout- Request timeout durationdirect_mode- If true, use direct API; if false, use proxyaccount_type- Account type for API endpoint selection
Sourcepub fn with_vision(self, enabled: bool) -> Self
pub fn with_vision(self, enabled: bool) -> Self
Enable vision mode for image processing.
Sourcepub async fn chat_completion(
&self,
request: ChatCompletionRequest,
) -> Result<ChatCompletionResponse>
pub async fn chat_completion( &self, request: ChatCompletionRequest, ) -> Result<ChatCompletionResponse>
Send a chat completion request (non-streaming).
Sourcepub async fn chat_completion_stream(
&self,
request: ChatCompletionRequest,
) -> Result<Response>
pub async fn chat_completion_stream( &self, request: ChatCompletionRequest, ) -> Result<Response>
Send a streaming chat completion request.
Sourcepub async fn list_models(&self) -> Result<ModelsResponse>
pub async fn list_models(&self) -> Result<ModelsResponse>
List available models.
Returns a list of models available for the authenticated user. Includes model capabilities, limits, and supported features.
Sourcepub async fn create_embeddings(
&self,
request: EmbeddingRequest,
) -> Result<EmbeddingResponse>
pub async fn create_embeddings( &self, request: EmbeddingRequest, ) -> Result<EmbeddingResponse>
Create embeddings for the given input.
§Arguments
request- The embedding request containing input text(s) and model
§Returns
Returns an EmbeddingResponse containing the embedding vectors.
§Example
ⓘ
let request = EmbeddingRequest::new("Hello, world!", "text-embedding-3-small");
let response = client.create_embeddings(request).await?;
let embedding = response.first_embedding().unwrap();Trait Implementations§
Source§impl Clone for VsCodeCopilotClient
impl Clone for VsCodeCopilotClient
Source§fn clone(&self) -> VsCodeCopilotClient
fn clone(&self) -> VsCodeCopilotClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for VsCodeCopilotClient
impl !RefUnwindSafe for VsCodeCopilotClient
impl Send for VsCodeCopilotClient
impl Sync for VsCodeCopilotClient
impl Unpin for VsCodeCopilotClient
impl UnsafeUnpin for VsCodeCopilotClient
impl !UnwindSafe for VsCodeCopilotClient
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