anthropic/client

HTTP client wrapper for Anthropic API calls

This module provides a client for making requests to the Anthropic Messages API, handling headers, timeouts, and response parsing.

Types

Client for making Anthropic API requests

pub type Client {
  Client(config: config.Config)
}

Constructors

  • Client(config: config.Config)

    Arguments

    config

    Configuration including API key and base URL

Values

pub const api_version: String

Current Anthropic API version

pub fn handle_response(
  response: response.Response(String),
) -> Result(String, error.AnthropicError)

Handle an API response, parsing success or error

pub const messages_endpoint: String

Messages API endpoint path

pub fn new(config: config.Config) -> Client

Create a new client from configuration

pub fn post_and_handle(
  client: Client,
  path: String,
  body: String,
) -> Result(String, error.AnthropicError)

Make a POST request and handle the response

pub fn post_json(
  client: Client,
  path: String,
  body: String,
) -> Result(response.Response(String), error.AnthropicError)

Make a POST request with JSON body to the specified path

Search Document