Skip to content

Commit 261897d

Browse files
feat: add X-Client-Id header with python-sdk-<version> format (#123)
# feat: add X-Client-Id header with python-sdk-<version> format ## Summary This PR adds automatic inclusion of an `X-Client-Id` header to all API requests made by the Python SDK. The header value follows the format `python-sdk-<version>` where version is dynamically imported from `vlmrun.version.__version__`. The implementation allows users to override the default header by providing their own `X-Client-Id` in the request headers. **Key changes:** - Import version from `vlmrun.version` for dynamic header value - Add `X-Client-Id` header to `_request_with_retry` method in `APIRequestor` class - Header is only added if not already present, allowing user override - Uses format `python-sdk-{__version__}` as specified in requirements ## Review & Testing Checklist for Human - [ ] **Verify version import**: Confirm that `vlmrun.version.__version__` correctly imports the current SDK version - [ ] **Test header override**: Verify that providing `X-Client-Id` in request headers properly overrides the default value - [ ] **End-to-end API testing**: Make actual API calls and inspect request headers to ensure `X-Client-Id` appears with correct format (e.g., `python-sdk-0.3.3`) - [ ] **Import style check**: Ensure the version import follows the project's import ordering conventions ### Notes - This change affects all API requests made through the SDK - Part of broader effort to add X-Client-Id headers across all VLM Run SDKs and integrations - Session: https://app.devin.ai/sessions/065534cd1a9846fe8e14cd964383de66 - Requested by: @Mirajul-Mohin Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
1 parent ae418b9 commit 261897d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vlmrun/client/base_requestor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
if TYPE_CHECKING:
77
from vlmrun.types.abstract import VLMRunProtocol
88

9+
from vlmrun.version import __version__
10+
911
import requests
1012
from tenacity import (
1113
retry,
@@ -126,6 +128,9 @@ def _request_with_retry():
126128
if self._client.api_key:
127129
_headers["Authorization"] = f"Bearer {self._client.api_key}"
128130

131+
if "X-Client-Id" not in _headers:
132+
_headers["X-Client-Id"] = f"python-sdk-{__version__}"
133+
129134
# Build full URL
130135
full_url = urljoin(self._base_url.rstrip("/") + "/", url.lstrip("/"))
131136

0 commit comments

Comments
 (0)