AI.Provider.Utils.JsonApi (AI SDK v0.0.1-rc.0)

View Source

Utility functions for making JSON API requests.

Summary

Functions

Makes a POST request to a JSON API endpoint.

Types

response()

@type response() :: {:ok, map()} | {:error, term()}

Functions

post(url, body, headers, options)

@spec post(String.t(), map(), map(), map()) :: response()

Makes a POST request to a JSON API endpoint.

Parameters

  • url - The URL to send the request to
  • body - The request body (will be converted to JSON)
  • headers - Map of HTTP headers
  • options - Additional options

Returns

  • {:ok, response} - The successful response
  • {:error, reason} - The error reason