Skip to main content

GatewaySDK

PyPI version License

AI Agent Training and Evaluation Platform

GatewaySDK is a comprehensive toolkit for training and evaluating AI agents using reinforcement learning, automatic prompt optimization, and supervised fine-tuning.

Core Features

  • Turn your agent into an optimizable beast with minimal code changes
  • Build with any agent framework (LangChain, OpenAI Agent SDK, AutoGen, CrewAI, and more)
  • Selectively optimize one or more agents in a multi-agent system
  • Embraces algorithms like Reinforcement Learning, Automatic Prompt Optimization, Supervised Fine-tuning and more

Installation

pip install gatewaysdk

For optional dependencies:

# For LLMProxy feature (note: has strict dependency pins for boto3, grpcio, uvicorn)
pip install 'gatewaysdk[proxy]'

# For Trainer (includes the proxy runtime it composes)
pip install 'gatewaysdk[trainer]'

# For GPU statistics in runner heartbeat snapshots
pip install 'gatewaysdk[gpu-monitoring]'

# For APO (Automatic Prompt Optimization)
pip install 'gatewaysdk[apo]'

# For VERL integration
pip install 'gatewaysdk[verl]'

# For Weave integration
pip install 'gatewaysdk[weave]'

# For MongoDB store
pip install 'gatewaysdk[mongo]'

Quick Start

from gatewaysdk import GatewayIngestionClient

# Reads GATEWAY_HOST, GATEWAY_PUBLIC_KEY, and GATEWAY_SECRET_KEY.
client = GatewayIngestionClient.from_env()

# Your agent code here...

Gateway Ingestion Helpers

Use these helpers when you want to send external agent traces/scores directly to a Gateway instance.

1) Gateway ingestion client

from gatewaysdk import GatewayIngestionClient, GatewayIngestionConfig

client = GatewayIngestionClient(
    GatewayIngestionConfig(
        host="http://localhost:3000",
        public_key="pk-lf-...",
        secret_key="sk-lf-...",
    )
)

# Send trace event
client.ingest_trace_event(
    trace_id="trace-001",
    name="Agent Trace",
    input_data={"prompt": "hello"},
    output_data={"answer": "world"},
    session_id="session-001",
    environment="default",
)

# Send scores efficiently in batches
client.send_scores(
    [
        {"name": "task_success", "value": 0.95, "dataType": "NUMERIC", "traceId": "trace-001"},
        {"name": "safety", "value": 1, "dataType": "BOOLEAN", "traceId": "trace-001"},
    ],
    mode="ingestion-batch",
)

2) Simple API wrapper sample (dependency-free)

For a minimal stdlib-only helper and examples, see: samples/gateway-agent-trace-wrapper/.

Security Wrapper

Use the security wrapper when Gateway should decide which native tools an agent can see and execute. Your framework keeps owning the tools; Gateway resolves policy, hides denied tools in filter/enforce modes, authorizes before execution, and stamps OpenTelemetry security attributes when tracing is active.

from gatewaysdk import GatewaySecurity

gw = GatewaySecurity.from_env(
    agent={
        "id": "support-triage",
        "name": "Support Triage",
        "version": "1.4.2",
    }
)

def search_tickets(query: str) -> list[dict]:
    return zendesk.search(query)

def delete_ticket(ticket_id: str) -> dict:
    return zendesk.delete(ticket_id)

tools = gw.secure_tools(
    toolset_id="zendesk",
    provider="zendesk",
    tools=[search_tickets, delete_ticket],
    context={
        "user_id": current_user.id,
        "team_id": "support",
        "environment": "production",
        "trace_id": trace_id,
        "session_id": session_id,
    },
)

CLI Usage

# Start the GatewaySDK server
msk store serve

# Run with vLLM
msk vllm start

Documentation

For full documentation, visit https://docs.gateway.dev/gatewaysdk/

License

MIT License - see LICENSE for details.

Metadata

Release files for gatewaysdk 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gatewaysdk 0.3.2
File Size Uploaded
gatewaysdk-0.3.2.tar.gz 2.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for gatewaysdk 0.3.2
File Interpreter ABI Platform
gatewaysdk-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 4.5 MB

Release files / gatewaysdk-0.3.2.tar.gz

Download URL gatewaysdk-0.3.2.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
a9a4c431b4b4a370fd0249ab96a4f0feb35c1c8f6731a4b53e1538c032661c93
BLAKE2b-256 checksum
How to use checksums
fcb8c9b8f20470b3bd77ba37443d57864b7d2638aaa7b800f4df10ff6d6fd1ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gatewaysdk-0.3.2-py3-none-any.whl

Download URL gatewaysdk-0.3.2-py3-none-any.whl
Size 1.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
bc92ef8a0832bf17872a9ae5c8885a47dc2f64ee122b48034186fd78044897ca
BLAKE2b-256 checksum
How to use checksums
cc38f9f9da0032d4a2b2654a2d49cbfbd01ed0ecd61886e601bde3a7b548b3cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.8.4

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.0

2 release files

0.3.6

2 release files

0.3.4

2 release files

0.3.3

2 release files

This release

0.3.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page