gleamstral/client
Types
Client for interacting with the Mistral AI API
Contains the API key required for authentication
pub type Client {
Client(api_key: String)
}
Constructors
-
Client(api_key: String)
Represents possible errors that can occur when interacting with the Mistral AI API
RateLimitExceeded
: Returned when API rate limits have been reachedUnauthorized
: Returned when API key is invalid or missingUnknown
: Returned for any other error, with the error message as a string
pub type Error {
RateLimitExceeded
Unauthorized
Unknown(String)
}
Constructors
-
RateLimitExceeded
-
Unauthorized
-
Unknown(String)
Constants
pub const api_endpoint: String
Functions
pub fn error_decoder() -> Decoder(Error)
pub fn handle_response(
response: Response(String),
using decoder: Decoder(a),
) -> Result(a, Error)
Handle HTTP responses from the Mistral AI API
Takes a response and a decoder, and returns either the decoded response or an appropriate error.
The generic type parameters allow this function to work with different request and response types.
pub fn new(api_key: String) -> Client
Creates a new Mistral AI client with the provided API key and HTTP client
Example
// Using gleam_httpc
import gleam_httpc
let client = client.new("your-api-key-here", httpc.send)
// Or using another HTTP client, like gleam_hackney
import hackney
let client = client.new("your-api-key-here", hackney.send)