o
    
j[                     @   s>   d Z ddlZddlmZmZ ddlmZmZ G dd dZdS )zMinimax API client base class.    N)AnyDict)MinimaxAuthErrorMinimaxRequestErrorc                   @   st   e Zd ZdZdedefddZdededeeef fd	d
Zdedeeef fddZ	dedeeef fddZ
dS )MinimaxAPIClientz/Base client for making requests to Minimax API.api_keyapi_hostc                 C   s4   || _ || _t | _| jjd| dd dS )zInitialize the API client.
        
        Args:
            api_key: The API key for authentication
            api_host: The API host URL
        zBearer zMinimax-MCP)AuthorizationzMM-API-SourceN)r   r   requestsSessionsessionheadersupdate)selfr   r    r   E/home/kuhnn/.local/lib/python3.10/site-packages/minimax_mcp/client.py__init__
   s   
zMinimaxAPIClient.__init__methodendpointreturnc           
   
   K   s<  | j  | }|d}|sd| jjd< n| jjdd zi| jj||fi |}|  | }|di }|ddkr|d dkrX td	|d
 d|jd dkrlt	d	|d
 d|jd 	 t	d	|d d|d
 d|jd |W S  t
jjy }	 z	t	dt|	 d}	~	ww )a  Make an HTTP request to the Minimax API.
        
        Args:
            method: HTTP method (GET, POST, etc.)
            endpoint: API endpoint path
            **kwargs: Additional arguments to pass to requests
            
        Returns:
            API response data as dictionary
            
        Raises:
            MinimaxAuthError: If authentication fails
            MinimaxRequestError: If the request fails
        fileszapplication/jsonzContent-TypeN	base_respstatus_coder   i  zAPI Error: 
status_msgz3, please check your API key and API host.Trace-Id: zTrace-Idi  z, should complete real-name verification on the open-platform(https://platform.minimaxi.com/user-center/basic-information).Trace-Id: -z Trace-Id: zRequest failed: )r   getr   r   poprequestraise_for_statusjsonr   r   r
   
exceptionsRequestExceptionstr)
r   r   r   kwargsurlr   responsedatar   er   r   r   _make_request   sF   




zMinimaxAPIClient._make_requestc                 K      | j d|fi |S )zMake a GET request.GETr(   r   r   r#   r   r   r   r   Y      zMinimaxAPIClient.getc                 K   r)   )zMake a POST request.POSTr+   r,   r   r   r   post]   r-   zMinimaxAPIClient.postN)__name__
__module____qualname____doc__r"   r   r   r   r(   r   r/   r   r   r   r   r      s    

@r   )	r3   r
   typingr   r   minimax_mcp.exceptionsr   r   r   r   r   r   r   <module>   s
    