Skip to main content

Gateagent Python SDK

Track and analyze your AI agent's tool interactions with deep insights.

Installation

pip install gateagent

Example: Math Agent

Here is a complete example of how to use gateagent with a LangChain agent:

from langchain_openai import ChatOpenAI
from langchain.tools import tool
from langchain_core.prompts import ChatPromptTemplate
from langsmith import traceable 
from gateagent import InteractionTracer

# 1. Initialize the Tracer
callbacks = [
    InteractionTracer(
        project_name="math-agent-playground",
        # tenant_id is derived from API Key on backend
        default_metadata={
            "agent": "math-agent-v1",
            "environment": "local",
        },
    )
]

# 2. Define Tools
@tool
def add_numbers(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

tools = [add_numbers]
tool_map = {t.name: t for t in tools}

llm = ChatOpenAI(model="gpt-4o-mini", temperature=0).bind_tools(tools)
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a math assistant."),
    ("human", "{input}"),
])
chain = prompt | llm

# 3. Use in execution (with @traceable or directly in config)
@traceable(run_type="chain", name="math-agent")
def run(input_text: str):
    response = chain.invoke(
        {"input": input_text},
        config={
            "callbacks": callbacks,
            "run_name": "math-agent-llm",
            "metadata": {"agent": "math-agent-v1"},
        },
    )
    
    if response.tool_calls:
        # Pass callbacks to tool execution logic
        tool_call = response.tool_calls[0]
        return tool_map[tool_call["name"]].invoke(
            tool_call["args"], 
            config={"callbacks": callbacks}
        )
    return response.content

Configuration

Set your API key via environment variable:

export GATEAGENT_API_KEY="your-api-key"

Or pass it to the Client explicitly if needed (advanced usage).

Release files for gateagent 0.1.9

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

Source distribution (sdist)

Source distribution for gateagent 0.1.9
File Size Uploaded
gateagent-0.1.9.tar.gz 4.8 kB Details

Built distribution (wheel)

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

Total release size: 10.1 kB

Release files / gateagent-0.1.9.tar.gz

Download URL gateagent-0.1.9.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
03a79a09c1acbcad1c40be694d55d3705547ae0107aa3032cfd19157ad0c0090
BLAKE2b-256 checksum
How to use checksums
0ed88d37e694a55ccd1285d5ed019c8c84a7a56abb43ed4f497df4c34ebe29b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / gateagent-0.1.9-py3-none-any.whl

Download URL gateagent-0.1.9-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4dd94b5ff8fb10d60274b90748527289fd10cf4052995a8bef3bb9baace3a7d6
BLAKE2b-256 checksum
How to use checksums
94b84ae1859de559ac26ba5d193e8c771c3c42478e8c8152d62eb4b7953afebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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