Skip to content

Commit 2f7e966

Browse files
committed
chore: update SDK client, memory docs, and tests
1 parent 1c54e38 commit 2f7e966

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+790
-790
lines changed

pkg/hanzo-memory/DOCS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ These capabilities support more personalized, contextually aware, and human-like
1212

1313
### Authentication
1414

15-
* **Production**: All endpoints require an API key provided via the `x-hanzo-api-key` HTTP header or set in the `HANZO_API_KEY` environment variable.
15+
* **Production**: All endpoints require an API key provided via the `x-api-key` HTTP header or set in the `HANZO_API_KEY` environment variable.
1616
* **Local Development**: Authentication can be disabled when running locally by setting `DISABLE_AUTH=true` or omitting the header.
1717

1818
> **Note:** All endpoints are RESTful and expect JSON request bodies with **lowercase** key names (e.g., `userid`, `messagecontent`). The `userid` parameter is **mandatory** for most endpoints; it partitions data per user to ensure multi-tenancy and security.
@@ -294,7 +294,7 @@ CREATE TABLE fact_relations (
294294

295295
### Endpoints
296296

297-
All endpoints require `userid` and either the `x-hanzo-api-key` header or `HANZO_API_KEY` environment variable (unless `DISABLE_AUTH=true`).
297+
All endpoints require `userid` and either the `x-api-key` header or `HANZO_API_KEY` environment variable (unless `DISABLE_AUTH=true`).
298298

299299
#### 1. POST /v1/knowledge/bases/create
300300

pkg/hanzo-memory/docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Authorization: Bearer YOUR_API_KEY
3030
```
3131

3232
Alternative authentication methods:
33-
- `x-hanzo-api-key` header
33+
- `x-api-key` header
3434
- `x-api-key` header
3535
- `apikey` in request body (for backwards compatibility)
3636

pkg/hanzo-memory/src/hanzo_memory/api/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_api_key(
1717
1818
Checks in order:
1919
1. Authorization header (Bearer token)
20-
2. x-hanzo-api-key header
20+
2. x-api-key header
2121
3. x-api-key header
2222
4. apikey in JSON body
2323
@@ -33,7 +33,7 @@ def get_api_key(
3333
return credentials.credentials
3434

3535
# Check custom headers
36-
api_key = request.headers.get("x-hanzo-api-key")
36+
api_key = request.headers.get("x-api-key")
3737
if api_key:
3838
return api_key
3939

pkg/hanzoai/_base_client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ def _build_headers(
426426
# Don't set these headers if they were already set or removed by the caller. We check
427427
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
428428
lower_custom_headers = [header.lower() for header in custom_headers]
429-
if "x-hanzo-retry-count" not in lower_custom_headers:
430-
headers["x-hanzo-retry-count"] = str(retries_taken)
431-
if "x-hanzo-read-timeout" not in lower_custom_headers:
429+
if "x-sdk-retry-count" not in lower_custom_headers:
430+
headers["x-sdk-retry-count"] = str(retries_taken)
431+
if "x-sdk-read-timeout" not in lower_custom_headers:
432432
timeout = (
433433
self.timeout
434434
if isinstance(options.timeout, NotGiven)
@@ -437,7 +437,7 @@ def _build_headers(
437437
if isinstance(timeout, Timeout):
438438
timeout = timeout.read
439439
if timeout is not None:
440-
headers["x-hanzo-read-timeout"] = str(timeout)
440+
headers["x-sdk-read-timeout"] = str(timeout)
441441

442442
return headers
443443

@@ -1984,12 +1984,12 @@ def get_platform() -> Platform:
19841984
@lru_cache(maxsize=None)
19851985
def platform_headers(version: str, *, platform: Platform | None) -> Dict[str, str]:
19861986
return {
1987-
"X-Hanzo-Lang": "python",
1988-
"X-Hanzo-Package-Version": version,
1989-
"X-Hanzo-OS": str(platform or get_platform()),
1990-
"X-Hanzo-Arch": str(get_architecture()),
1991-
"X-Hanzo-Runtime": get_python_runtime(),
1992-
"X-Hanzo-Runtime-Version": get_python_version(),
1987+
"X-SDK-Lang": "python",
1988+
"X-SDK-Package-Version": version,
1989+
"X-SDK-OS": str(platform or get_platform()),
1990+
"X-SDK-Arch": str(get_architecture()),
1991+
"X-SDK-Runtime": get_python_runtime(),
1992+
"X-SDK-Runtime-Version": get_python_version(),
19931993
}
19941994

19951995

pkg/hanzoai/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def auth_headers(self) -> dict[str, str]:
488488
def default_headers(self) -> dict[str, str | Omit]:
489489
return {
490490
**super().default_headers,
491-
"X-Hanzo-Async": "false",
491+
"X-SDK-Async": "false",
492492
**self._custom_headers,
493493
}
494494

@@ -932,7 +932,7 @@ def auth_headers(self) -> dict[str, str]:
932932
def default_headers(self) -> dict[str, str | Omit]:
933933
return {
934934
**super().default_headers,
935-
"X-Hanzo-Async": f"async:{get_async_library()}",
935+
"X-SDK-Async": f"async:{get_async_library()}",
936936
**self._custom_headers,
937937
}
938938

pkg/hanzoai/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import httpx
44

5-
RAW_RESPONSE_HEADER = "X-Hanzo-Raw-Response"
5+
RAW_RESPONSE_HEADER = "X-SDK-Raw-Response"
66
OVERRIDE_CAST_TO_HEADER = "____hanzo_override_cast_to"
77

88
# default timeout is 1 minute

pkg/hanzoai/resources/cache/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def delete(
6464
"""Endpoint for deleting a key from the cache.
6565
6666
All responses from hanzo proxy
67-
have `x-hanzo-cache-key` in the headers
67+
have `x-cache-key` in the headers
6868
6969
Parameters:
7070
@@ -180,7 +180,7 @@ async def delete(
180180
"""Endpoint for deleting a key from the cache.
181181
182182
All responses from hanzo proxy
183-
have `x-hanzo-cache-key` in the headers
183+
have `x-cache-key` in the headers
184184
185185
Parameters:
186186

pkg/hanzoai/resources/model/info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def list(
6161
descriptions (except api key and api base)
6262
6363
Parameters: hanzo_model_id: Optional[str] = None (this is the value of
64-
`x-hanzo-model-id` returned in response headers)
64+
`x-model-id` returned in response headers)
6565
6666
- When hanzo_model_id is passed, it will return the info for that specific model
6767
- When hanzo_model_id is not passed, it will return the info for all models
@@ -148,7 +148,7 @@ async def list(
148148
descriptions (except api key and api base)
149149
150150
Parameters: hanzo_model_id: Optional[str] = None (this is the value of
151-
`x-hanzo-model-id` returned in response headers)
151+
`x-model-id` returned in response headers)
152152
153153
- When hanzo_model_id is passed, it will return the info for that specific model
154154
- When hanzo_model_id is not passed, it will return the info for all models

tests/api_resources/audio/test_speech.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ def test_raw_response_create(self, client: Hanzo) -> None:
2626
response = client.audio.speech.with_raw_response.create()
2727

2828
assert response.is_closed is True
29-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
29+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
3030
speech = response.parse()
3131
assert_matches_type(object, speech, path=["response"])
3232

3333
@parametrize
3434
def test_streaming_response_create(self, client: Hanzo) -> None:
3535
with client.audio.speech.with_streaming_response.create() as response:
3636
assert not response.is_closed
37-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
37+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
3838

3939
speech = response.parse()
4040
assert_matches_type(object, speech, path=["response"])
@@ -55,15 +55,15 @@ async def test_raw_response_create(self, async_client: AsyncHanzo) -> None:
5555
response = await async_client.audio.speech.with_raw_response.create()
5656

5757
assert response.is_closed is True
58-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
58+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
5959
speech = await response.parse()
6060
assert_matches_type(object, speech, path=["response"])
6161

6262
@parametrize
6363
async def test_streaming_response_create(self, async_client: AsyncHanzo) -> None:
6464
async with async_client.audio.speech.with_streaming_response.create() as response:
6565
assert not response.is_closed
66-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
66+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
6767

6868
speech = await response.parse()
6969
assert_matches_type(object, speech, path=["response"])

tests/api_resources/audio/test_transcriptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_raw_response_create(self, client: Hanzo) -> None:
3030
)
3131

3232
assert response.is_closed is True
33-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
33+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
3434
transcription = response.parse()
3535
assert_matches_type(object, transcription, path=["response"])
3636

@@ -40,7 +40,7 @@ def test_streaming_response_create(self, client: Hanzo) -> None:
4040
file=b"raw file contents",
4141
) as response:
4242
assert not response.is_closed
43-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
43+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
4444

4545
transcription = response.parse()
4646
assert_matches_type(object, transcription, path=["response"])
@@ -65,7 +65,7 @@ async def test_raw_response_create(self, async_client: AsyncHanzo) -> None:
6565
)
6666

6767
assert response.is_closed is True
68-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
68+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
6969
transcription = await response.parse()
7070
assert_matches_type(object, transcription, path=["response"])
7171

@@ -75,7 +75,7 @@ async def test_streaming_response_create(self, async_client: AsyncHanzo) -> None
7575
file=b"raw file contents",
7676
) as response:
7777
assert not response.is_closed
78-
assert response.http_request.headers.get("X-Hanzo-Lang") == "python"
78+
assert response.http_request.headers.get("X-SDK-Lang") == "python"
7979

8080
transcription = await response.parse()
8181
assert_matches_type(object, transcription, path=["response"])

0 commit comments

Comments
 (0)