Official Python SDK for the Gateplex AI observability platform
Project description
gateplex-python
Official Python SDK for Gateplex — AI agent observability, guardrails, and monitoring.
Installation
pip install gateplex-python
Optional extras for LLM auto-patching:
pip install "gateplex-python[openai]" # OpenAI support
pip install "gateplex-python[anthropic]" # Anthropic support
pip install "gateplex-python[all]" # Everything
Quick start
from gateplex import GateplexClient
client = GateplexClient(api_key="gplx_your_key_here")
response = client.log_intercept(
agent_id="my-agent-uuid",
event_type="llm_call", # "llm_call" | "tool_call" | "guardrail_trigger"
input="What is the capital of France?",
output="Paris.",
model="gpt-4o",
latency_ms=342,
flagged=False,
metadata={"user_id": "u_123"},
)
print(response.intercept_id) # uuid
print(response.flagged) # bool
Features
Automatic latency measurement — context manager
with client.capture(
agent_id="my-agent",
event_type="llm_call",
input=user_prompt,
model="gpt-4o",
) as ctx:
ctx.output = call_my_llm(user_prompt) # latency measured automatically
@monitor decorator
from gateplex import monitor
@monitor(client, agent_id="my-agent", event_type="llm_call", model="gpt-4o")
def call_llm(input: str) -> str:
return openai_client.chat.completions.create(...)
Background batch logging
Fire-and-forget for high-throughput pipelines:
# Enqueued immediately, sent by a background thread
client.batch_intercept(
agent_id="my-agent",
event_type="tool_call",
input='search("latest AI news")',
output='["OpenAI launches...", ...]',
model="gpt-4o",
)
# Force flush before process exit
client.flush()
OpenAI auto-patcher
Automatically intercepts every chat.completions.create call:
import openai
from gateplex import GateplexClient
from gateplex import OpenAIPatcher
gp = GateplexClient(api_key="gplx_...")
oai = openai.OpenAI(api_key="sk-...")
patcher = OpenAIPatcher(gp, agent_id="my-agent", openai_client=oai)
patcher.patch()
# Use oai normally — all calls are logged
response = oai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
patcher.unpatch() # remove when done
Anthropic auto-patcher
import anthropic
from gateplex import GateplexClient
from gateplex import AnthropicPatcher
gp = GateplexClient(api_key="gplx_...")
ant = anthropic.Anthropic(api_key="sk-ant-...")
patcher = AnthropicPatcher(gp, agent_id="my-agent", anthropic_client=ant)
patcher.patch()
message = ant.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
patcher.unpatch()
Public REST endpoints
# List intercepts (paginated)
intercepts = client.get_intercepts(limit=20, offset=0, agent_id="my-agent")
# Create an intercept via the public REST API
result = client.create_intercept(
agent_id="my-agent",
event_type="llm_call",
input="Hello",
output="Hi!",
model="gpt-4o",
)
# Fetch guardrail definitions
guardrails = client.get_guardrails()
for g in guardrails:
print(g.name, g.enabled)
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
— | Your gplx_... API key (required) |
timeout |
10.0 |
HTTP timeout in seconds |
max_retries |
3 |
Retries with exponential back-off (on 429/5xx) |
batch_size |
50 |
Max events in background queue before forced flush |
flush_interval |
5.0 |
Seconds between background flushes |
raise_on_error |
False |
Set True to surface API errors instead of logging them |
client = GateplexClient(
api_key="gplx_...",
timeout=5.0,
max_retries=5,
flush_interval=2.0,
raise_on_error=True, # great for dev/test
)
Error handling
from gateplex import GateplexAuthError, GateplexAPIError
try:
client.log_intercept(...)
except GateplexAuthError:
print("Check your API key")
except GateplexAPIError as e:
print(f"API error: {e}")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gateplex_python-0.2.0.tar.gz.
File metadata
- Download URL: gateplex_python-0.2.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
968df269d02116719973a693424bb10f628a5aafe4d0634ff1f30d30f48fe942
|
|
| MD5 |
17eee1cf56b1c4b1284a210f854bf97b
|
|
| BLAKE2b-256 |
3908b8fc0f89672b500cfc649e07d9f3fb11df9bc58f1e428bc3cec72f21bf9a
|
File details
Details for the file gateplex_python-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gateplex_python-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
503943c79232cf1366c3853fd29de7bb0f4f0efa34ce18aff36e3152ab792986
|
|
| MD5 |
eb4bfa2f468460d00729b8c555391422
|
|
| BLAKE2b-256 |
ba3ab5d4626fa531bf40f8c21cfd019749abfb54ace6d364642d2f694532fd3c
|