HTTP transport layer for the MIOSA API.
Holds configuration and wraps Req for all request types: JSON API calls,
multipart file uploads, binary downloads, and SSE streaming.
Construct a client via Miosa.client/2 rather than using this module directly.
Options
:api_key— Required. API key starting withmsk_.:base_url— Override the API base URL. Defaults tohttps://api.miosa.ai/api/v1.:timeout— Request timeout in milliseconds. Defaults to30_000.:receive_timeout— Receive timeout for long-running requests. Defaults to60_000.:retry— Whether to retry failed requests. Defaults tofalse.
Summary
Functions
Performs a DELETE request and decodes the JSON response.
Performs a GET request and decodes the JSON response.
Performs a GET request and returns the raw binary response body.
Builds a new Miosa.Client struct.
Performs a PATCH request with a JSON body and decodes the response.
Performs a POST request with a JSON body and decodes the response.
Performs a multipart POST for file uploads.
Performs a PUT request with a JSON body and decodes the response.
Opens an SSE stream and calls callback for each parsed event.
Types
@type result(type) :: {:ok, type} | {:error, Miosa.Error.t()}
@type t() :: %Miosa.Client{ _req: Req.Request.t(), api_key: String.t(), base_url: String.t(), receive_timeout: pos_integer(), retry: boolean(), timeout: pos_integer() }
Functions
Performs a DELETE request and decodes the JSON response.
Performs a GET request and decodes the JSON response.
Performs a GET request and returns the raw binary response body.
Used for downloading files and screenshots.
Builds a new Miosa.Client struct.
Validates the API key format and constructs a base Req request with
default headers and options pre-applied.
Performs a PATCH request with a JSON body and decodes the response.
Performs a POST request with a JSON body and decodes the response.
Performs a multipart POST for file uploads.
parts should be a list of {name, value} tuples or {name, value, opts} tuples
compatible with Req's :form_multipart option.
Performs a PUT request with a JSON body and decodes the response.
@spec stream_sse(t(), String.t(), function(), keyword()) :: :ok | {:error, Miosa.Error.t()}
Opens an SSE stream and calls callback for each parsed event.
The callback receives {event_type :: String.t(), data :: String.t()} tuples.
The stream is consumed until the connection closes or the server sends data: [DONE].
Returns :ok when the stream completes or {:error, reason} on failure.