agentle.agents.apis.endpoint

API endpoint integration for Agentle framework.

This module provides classes for defining HTTP API endpoints that can be automatically converted to tools for use by AI agents. This allows users to integrate with REST APIs without writing HTTP request functions manually.

Example: ```python from agentle.apis.endpoint import Endpoint, API, HTTPMethod, ParameterLocation, EndpointParameter from agentle.agents.agent import Agent

# Define individual endpoints weather_endpoint = Endpoint(

name=”get_weather”, description=”Get current weather for a location”, call_condition=”when user asks about weather, current conditions, or temperature”, url=”https://api.weather.com/v1/current”, method=HTTPMethod.GET, parameters=[

EndpointParameter(

name=”location”, description=”City name or coordinates”, param_type=”string”, location=ParameterLocation.QUERY, required=True

), EndpointParameter(

name=”units”, description=”Temperature units”, param_type=”string”, location=ParameterLocation.QUERY, default=”metric”

)

]

)

# Or define an API with multiple endpoints weather_api = API(

name=”WeatherAPI”, base_url=”https://api.weather.com/v1”, headers={“Authorization”: “Bearer YOUR_TOKEN”}, endpoints=[

Endpoint(

name=”get_current_weather”, description=”Get current weather conditions”, call_condition=”when user asks about current weather”, path=”/current”, method=HTTPMethod.GET, parameters=[

EndpointParameter(“location”, “Location to get weather for”, “string”,

ParameterLocation.QUERY, required=True)

]

), Endpoint(

name=”get_forecast”, description=”Get weather forecast”, call_condition=”when user asks about weather forecast or future weather”, path=”/forecast”, method=HTTPMethod.GET, parameters=[

EndpointParameter(“location”, “Location for forecast”, “string”,

ParameterLocation.QUERY, required=True),

EndpointParameter(“days”, “Number of days”, “integer”,

ParameterLocation.QUERY, default=5)

]

)

]

)

# Use with an agent agent = Agent(

generation_provider=GoogleGenerationProvider(), model=”gemini-2.5-flash”, instructions=”You are a weather assistant.”, tools=[weather_endpoint], # Individual endpoint apis=[weather_api] # Full API with multiple endpoints

)

Functions

Field()

!!! abstract "Usage Documentation"

Classes

Any(*args, **kwargs)

Special type indicating an unconstrained type.

BaseModel()

Alias for pydantic.BaseModel.

Endpoint(*, name, description[, ...])

Represents a single HTTP API endpoint that can be called by an agent.

EndpointParameter(*, name, description[, ...])

Represents a parameter for an API endpoint with proper object support.

HTTPMethod(*values)

HTTP methods supported by endpoints.

MutableMapping()

A MutableMapping is a generic container for associating key/value pairs.

ParameterLocation(*values)

Where to place parameters in the HTTP request.

RequestConfig(*[, timeout, max_retries, ...])

Configuration for HTTP requests.

Sequence()

All the operations on a read-only sequence.

Tool(*[, type, description, ignore_errors])

A callable tool that can be used by AI models to perform specific functions.