MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / chat

Method chat

crates/opencode-provider/src/groq.rs:99–120  ·  view source on GitHub ↗
(&self, request: ChatRequest)

Source from the content-addressed store, hash-verified

97 }
98
99 async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
100 let response = self
101 .client
102 .post(GROQ_API_URL)
103 .header("Authorization", format!("Bearer {}", self.api_key))
104 .header("Content-Type", "application/json")
105 .json(&request)
106 .send()
107 .await
108 .map_err(|e| ProviderError::NetworkError(e.to_string()))?;
109
110 if !response.status().is_success() {
111 let status = response.status();
112 let body = response.text().await.unwrap_or_default();
113 return Err(ProviderError::ApiError(format!("{}: {}", status, body)));
114 }
115
116 response
117 .json()
118 .await
119 .map_err(|e| ProviderError::ApiError(e.to_string()))
120 }
121
122 async fn chat_stream(&self, request: ChatRequest) -> Result<StreamResult, ProviderError> {
123 let mut stream_request = request;

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected