The gateway, now in the language your LLM app is written in
Most production LLM code is Python. The frameworks are Python, the agent tooling is Python, and when a library in this space gets archived, it's the Python teams who feel it first. Until today, Grepture's SDK story was TypeScript only: the proxy always worked from any language (it's a base URL), but trace mode, prompt helpers, and the ergonomic client wiring lived in @grepture/sdk alone.
That gap is closed. pip install grepture gives Python everything the TypeScript SDK does, sync and async, on Python 3.9+ with httpx as the only dependency.
One line into your existing client
The SDK plugs into any OpenAI-shaped client through client_options(). It returns the base URL, key, and a pre-wired HTTP client, so your existing code keeps working unchanged:
import os
from openai import OpenAI
from grepture import Grepture
grepture = Grepture(
api_key=os.environ["GREPTURE_API_KEY"],
proxy_url="https://proxy.grepture.com",
)
client = OpenAI(
**grepture.client_options(
api_key=os.environ["OPENAI_API_KEY"],
base_url="https://api.openai.com/v1",
)
)
# Every request is now scanned, redacted, and logged
response = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": user_input}],
)
The same pattern works with the Anthropic SDK, Azure OpenAI, and any OpenAI-compatible provider. Under the hood it's a custom httpx transport, not a monkeypatch: we rewrite the request path and headers at the transport layer, which means it survives SDK upgrades and covers streaming without special cases. Your provider key is forwarded via X-Grepture-Auth-Forward; reversible redaction and secret scanning run before anything else.
Trace mode: observability without the hop
Proxy mode puts Grepture on the request path. Trace mode doesn't: requests go directly to the provider, and the SDK captures tokens, model, latency, and cost in the background, batched and shipped asynchronously.
grepture = Grepture(
api_key=os.environ["GREPTURE_API_KEY"],
proxy_url="https://proxy.grepture.com",
mode="trace",
)
client = OpenAI(**grepture.client_options(
api_key=os.environ["OPENAI_API_KEY"],
base_url="https://api.openai.com/v1",
))
# ... your calls run at full provider speed ...
grepture.flush() # deliver the last batch before exit (serverless!)
Streaming is handled with a teeing byte stream: chunks pass through to your code untouched while the SDK captures just enough of the SSE tail to extract usage. Zero added latency, and the trace still lands.
For asyncio apps there's AsyncGrepture with the identical surface: AsyncOpenAI(**grepture.client_options(...)), await grepture.flush().
Everything else came along
- Labels, metadata, and log events for cost attribution:
set_label("summarize"),set_metadata({"team": "support"}),log("cache-hit", {...}). - Prompt management:
grepture.prompt.use()for server-side resolution through the proxy,assemble()for local resolution in trace mode, with the same Handlebars-style templates as the dashboard. - PII-safe embeddings:
grepture.embeddings.create(...)redacts before embedding, and blocked requests raise an error carrying the detected categories. - Typed errors (
BlockedError,AuthError,ProxyError) so a blocked request is a catchable exception, not a mystery 403.
Parity is tested, not promised
Two SDKs speaking one wire protocol drift apart unless something stops them. Our something is a fixture suite: the Python tests pin the exact header names, trace-entry JSON shape, and batching constants the TypeScript SDK emits, down to details like JavaScript truthiness in template resolution (an empty object is truthy in JS, so it is in our Python port too) and float-tolerant token counts. If a future change breaks parity, a test fails before a request does.
Where the platforms genuinely differ, we matched behavior deliberately: Python's client_options() returns an http_client where TypeScript returns a fetch wrapper, and both carry your configured timeouts through untouched.
Getting started
The redact-pii guides now show TypeScript and Python side by side with a language switcher, and the examples repo has four runnable Python scripts covering proxy mode, trace mode, labels, and asyncio. The SDK itself is open source: the code and issue tracker live at grepture/sdk-python.
If you're coming from an archived guardrails library, the llm-guard migration guide now has a first-class answer for its "after" snippet: the code you migrate to is a base URL change plus pip install grepture, and the scanner chain you delete never comes back.