adk_model_http_transport behaviour (erlang_adk v0.8.0)

View Source

Injected bounded HTTP transport contract for model providers.

Provider adapters pass credentials only in the private request value. A transport must neither log nor retain them, must enforce the supplied scheme/host policy after DNS resolution, must not follow redirects, and must stop reading once max_response_bytes is reached.

Summary

Types

chunk_callback/0

-type chunk_callback() :: fun((binary()) -> ok | {error, term()}).

handle/0

-type handle() :: term().

request/0

-type request() ::
          #{method := binary(),
            url := binary(),
            headers := [{binary(), binary()}],
            body := binary(),
            timeout_ms := pos_integer(),
            max_response_bytes := pos_integer(),
            follow_redirects := false,
            allowed_schemes := [binary()],
            allowed_hosts := [binary()],
            allow_private_hosts := boolean()}.

response/0

-type response() :: #{status := 100..599, headers => [{binary(), binary()}] | map(), body := binary()}.

Callbacks

request/2

-callback request(Handle :: handle(), Request :: request()) -> {ok, response()} | {error, term()}.

stream/3

-callback stream(Handle :: handle(), Request :: request(), Callback :: chunk_callback()) ->
                    {ok, response()} | {error, term()}.