Class HttpApiToolDefinition
A tool that calls one HTTP API operation, described as data: the method, a URL template whose
{name} placeholders are filled from the arguments, fixed headers, the JSON schema of the
arguments the model passes, and the part of the answer to keep. HttpApiTool runs it;
OpenApiImporter makes definitions from an OpenAPI document. Plain JSON, so a host
stores, exports and edits it like any other definition.
public sealed class HttpApiToolDefinition
- Inheritance
-
HttpApiToolDefinition
- Inherited Members
Examples
{
"name": "find_customer",
"description": "Find a customer by email address.",
"method": "GET",
"url": "https://crm.example.com/api/customers?email={email}",
"headers": { "Authorization": "Bearer ..." },
"input_schema": { "type": "object", "properties": { "email": { "type": "string" } }, "required": ["email"] },
"response_path": "data.0"
}
Fields
- BodyLocation
Where an argument goes: into the JSON body.
- HeaderLocation
Where an argument goes: into a request header.
- PathLocation
Where an argument goes: into the URL path.
- QueryLocation
Where an argument goes: into the query string.
Properties
- Description
Gets or sets what the tool does, as the model reads it.
- Headers
Gets or sets the headers every call sends (an API key, an accept type).
- InputSchema
Gets or sets the JSON schema of the arguments; null derives one from the URL's placeholders, each a required string.
- IsReadOnly
Gets whether the method only reads (GET or HEAD).
- MaxResponseChars
Gets or sets the most characters of the answer the model receives.
- Method
Gets or sets the HTTP method: GET, POST, PUT, PATCH, DELETE or HEAD.
- Name
Gets or sets the tool's name, as the model calls it.
- ParameterLocations
Gets or sets where each argument goes (PathLocation, QueryLocation, HeaderLocation, BodyLocation). An argument not listed goes into the path when the URL names it, else into the query string for GET, HEAD and DELETE and into the JSON body otherwise.
- RequiresApproval
Gets or sets whether a call needs a person's approval before it runs; null decides by the method (a call that only reads runs, any other asks first).
- ResponsePath
Gets or sets the part of a JSON answer to keep, as a dotted path (
data.items,results.0.name); empty keeps the whole answer.
- Retries
Gets or sets how many times a call is sent again after a transient failure (no answer, a timeout, or HTTP 408, 429, 502, 503 or 504), waiting longer each time and honoring
Retry-After. Only a method that may be repeated (GET, HEAD, PUT, DELETE, OPTIONS) is retried; a POST or PATCH is sent once. From 0 to 5.
- TimeoutSeconds
Gets or sets how long a call may take, in seconds.
- Url
Gets or sets the absolute URL, where
{name}is replaced by the escaped value of the argument of that name.
Methods
- FromJson(string)
Reads a definition from its JSON form.
- LocationOf(string)
Where an argument goes, by ParameterLocations or by default.
- SchemaJson()
The schema the model reads: the declared one, or one string argument per URL placeholder.
- ToJson()
Writes the definition as JSON.
- UrlParameters()
The names of the URL's placeholders, in order.
- Validate()
Why the definition cannot run, every reason at once; empty when it can.