MistralClient.Behaviours.HttpClient behaviour (mistralex_ai v0.1.0)
View SourceBehaviour for HTTP client implementations.
This behaviour defines the contract for HTTP clients used by the Mistral SDK. It allows for easy mocking in tests while maintaining a consistent interface.
Summary
Types
Callbacks
Performs an HTTP request.
Parameters
method
- HTTP method (:get, :post, :put, :patch, :delete)url
- Request URLheaders
- List of request headers as tuplesbody
- Request body (string, map, or nil)options
- Additional options (timeout, etc.)
Returns
{:ok, response}
- Successful response with parsed body{:error, reason}
- Error response
@callback stream_request(method(), url(), headers(), body(), options()) :: {:ok, Enumerable.t()} | {:error, term()}
Performs a streaming HTTP request for Server-Sent Events.
Parameters
method
- HTTP method (typically :post for streaming)url
- Request URLheaders
- List of request headers as tuplesbody
- Request body (string, map, or nil)options
- Additional options including stream handling
Returns
{:ok, stream}
- Stream of events{:error, reason}
- Error response