Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/blaxel/core/common/autoload.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ def telemetry() -> None:
def autoload() -> None:
client.with_base_url(settings.base_url)
client.with_auth(settings.auth)
# Send the Blaxel-Version header on every control-plane request so list
# endpoints return cursor-paginated `{data, meta}` responses (>= 2026-04-28).
# Without it the API falls back to legacy bare-array listings and pagination
# (limit/cursor/next_page) is silently ignored.
client.with_headers({"Blaxel-Version": settings.api_version})
# Send SDK-identifying headers on every control-plane request so backend
# observability can classify Python SDK traffic and list endpoints return
# cursor-paginated `{data, meta}` responses (>= 2026-04-28). Without the
# User-Agent httpx falls back to `python-httpx/<version>`, which is tracked
# as a generic API request instead of SDK usage.
client.with_headers(
{
"Blaxel-Version": settings.api_version,
"User-Agent": settings.headers["User-Agent"],
}
)

# Register response interceptors for authentication error handling
# Access the underlying httpx clients and add event hooks
Expand Down
13 changes: 13 additions & 0 deletions tests/core/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ def test_autoload_functionality():
raise


def test_autoload_sets_control_plane_user_agent():
"""Control-plane requests should carry the Python SDK User-Agent."""
from blaxel.core.client import client
from blaxel.core.common.autoload import autoload
from blaxel.core.common.settings import settings

autoload()

assert client._headers["Blaxel-Version"] == settings.api_version
assert client._headers["User-Agent"] == settings.headers["User-Agent"]
assert client._headers["User-Agent"].startswith("blaxel/sdk/python/")


def test_settings_properties():
"""Test that settings has the expected properties."""
from blaxel.core.common.settings import settings
Expand Down
Loading