MCPcopy Create free account
hub / github.com/OpenRouterTeam/python-sdk / do

Method do

src/openrouter/basesdk.py:252–288  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250 hooks = self.sdk_configuration.__dict__["_hooks"]
251
252 def do():
253 http_res = None
254 try:
255 req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
256 if "timeout" in request.extensions and "timeout" not in req.extensions:
257 req.extensions["timeout"] = request.extensions["timeout"]
258 logger.debug(
259 "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
260 req.method,
261 req.url,
262 req.headers,
263 get_body_content(req),
264 )
265
266 if client is None:
267 raise ValueError("client is required")
268
269 http_res = client.send(req, stream=stream)
270 except Exception as e:
271 _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
272 if e is not None:
273 logger.debug("Request Exception", exc_info=True)
274 raise e
275
276 if http_res is None:
277 logger.debug("Raising no response SDK error")
278 raise errors.NoResponseError("No response received")
279
280 logger.debug(
281 "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
282 http_res.status_code,
283 http_res.url,
284 http_res.headers,
285 "<streaming response>" if stream else http_res.text,
286 )
287
288 return http_res
289
290 if retry_config is not None:
291 http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))

Callers

nothing calls this directly

Calls 8

get_body_contentFunction · 0.90
AfterErrorContextClass · 0.90
run_sync_in_threadFunction · 0.90
before_requestMethod · 0.45
debugMethod · 0.45
sendMethod · 0.45
after_errorMethod · 0.45

Tested by

no test coverage detected