The docs export only variables the SDK reads

The backend guide exported HANZO_ROUTER_URL and HANZO_API_KEY as a setup
step, but the SDK takes its endpoint and key from the client it is
given, and the openai client falls back to OPENAI_BASE_URL and
OPENAI_API_KEY. Reading HANZO_ROUTER_URL as well would be a second way
to set one thing, so the step is gone and the pooling example names
https://api.hanzo.ai/v1. A test fails when the docs export a variable
that neither package reads.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-09-11 13:50:13 -07:00
co-authored by Hanzo Dev
parent 9e1118f21d
commit e1cd400abd
2 changed files with 37 additions and 15 deletions
+3 -15
View File
@@ -14,7 +14,7 @@ The Hanzo Agent SDK can be configured to route all LLM requests through the Hanz
## Quick Start
### 1. Install the SDK
### Install the SDK
```bash
pip install hanzo-agent
@@ -22,19 +22,7 @@ pip install hanzo-agent
uv pip install hanzo-agent
```
### 2. Configure Environment
```bash
# Local development
export HANZO_ROUTER_URL="http://localhost:4000/v1"
export HANZO_API_KEY="sk-1234" # Get from Router dashboard
# Production
export HANZO_ROUTER_URL="https://router.your-domain.com/v1"
export HANZO_API_KEY="sk-production-key"
```
### 3. Basic Usage
### Basic Usage
```python
from openai import AsyncOpenAI
@@ -207,7 +195,7 @@ def get_hanzo_provider():
global _hanzo_provider
if _hanzo_provider is None:
_hanzo_provider = HanzoModelProvider(
base_url=os.getenv("HANZO_ROUTER_URL"),
base_url="https://api.hanzo.ai/v1",
api_key=os.getenv("HANZO_API_KEY")
)
return _hanzo_provider
+34
View File
@@ -0,0 +1,34 @@
"""The docs configure the SDK only through variables that code reads."""
from __future__ import annotations
import re
from pathlib import Path
import openai
import agents
ROOT = Path(__file__).resolve().parents[1]
def _names(package: Path) -> set[str]:
return {
name
for path in package.rglob("*.py")
for name in re.findall(r"\b[A-Z][A-Z0-9_]+\b", path.read_text(encoding="utf-8"))
}
def test_every_variable_the_docs_export_is_read() -> None:
# The SDK reads its own variables, and the openai client it builds reads OPENAI_API_KEY and
# OPENAI_BASE_URL.
read = _names(Path(agents.__file__).parent) | _names(Path(openai.__file__).parent)
exported = [
(str(doc.relative_to(ROOT)), name)
for doc in [ROOT / "README.md", *sorted(ROOT.glob("docs/**/*.md"))]
for name in re.findall(
r"^\s*export ([A-Z][A-Z0-9_]*)=", doc.read_text(encoding="utf-8"), re.MULTILINE
)
]
assert [item for item in exported if item[1] not in read] == []