MCPcopy Create free account
hub / github.com/Open-Bee/DataStudio / _build_openai_headers

Method _build_openai_headers

datastudio/models/base.py:315–327  ·  view source on GitHub ↗

Build HTTP headers for OpenAI-compatible API request. Args: api_key: API key for authorization. If empty, no Authorization header. Returns: Headers dict with Content-Type and optional Authorization.

(self, api_key: str)

Source from the content-addressed store, hash-verified

313 return content
314
315 def _build_openai_headers(self, api_key: str) -> dict:
316 """Build HTTP headers for OpenAI-compatible API request.
317
318 Args:
319 api_key: API key for authorization. If empty, no Authorization header.
320
321 Returns:
322 Headers dict with Content-Type and optional Authorization.
323 """
324 headers = {"Content-Type": "application/json"}
325 if api_key:
326 headers["Authorization"] = f"Bearer {api_key}"
327 return headers
328
329 def _calculate_retry_delay(self, attempt: int, max_delay: float = 2.0) -> float:
330 """Calculate exponential backoff delay with full jitter.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected