MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / chat

Method chat

crates/opencode-provider/src/azure.rs:147–171  ·  view source on GitHub ↗
(&self, request: ChatRequest)

Source from the content-addressed store, hash-verified

145 }
146
147 async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
148 let url = self.build_url(&request.model, false);
149 let request_body = Self::build_request_body(&request)?;
150
151 let response = self
152 .client
153 .post(&url)
154 .header("api-key", &self.config.api_key)
155 .header("Content-Type", "application/json")
156 .json(&request_body)
157 .send()
158 .await
159 .map_err(|e| ProviderError::NetworkError(e.to_string()))?;
160
161 if !response.status().is_success() {
162 let status = response.status();
163 let body = response.text().await.unwrap_or_default();
164 return Err(ProviderError::ApiError(format!("{}: {}", status, body)));
165 }
166
167 response
168 .json()
169 .await
170 .map_err(|e| ProviderError::ApiError(e.to_string()))
171 }
172
173 async fn chat_stream(&self, request: ChatRequest) -> Result<StreamResult, ProviderError> {
174 let url = self.build_url(&request.model, true);

Callers

nothing calls this directly

Calls 5

ApiErrorEnum · 0.50
build_urlMethod · 0.45
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected