CerebrasClient

CerebrasClient(api_key=None, **kwargs)

Client for Cerebras’s API.
Requires api_key or environment variable to be set

Parameters:
NameDescription
api_key=None
**kwargs

Static Methods

get_usage

get_usage(response: ChatCompletion) -> dict

Return usage summary of the response using RESPONSE_USAGE_KEYS.

Parameters:
NameDescription
responseType: ChatCompletion

Instance Methods

cost

cost(self, response: ChatCompletion) -> float
Parameters:
NameDescription
responseType: ChatCompletion

create

create(*args, **kwargs) -> 

Call self as a function.

Parameters:
NameDescription
*args
**kwargs

message_retrieval

message_retrieval(self, response: ChatCompletion) -> list

Retrieve and return a list of strings or a list of Choice.Message from the response.
NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI’s ChatCompletion Message object, since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.

Parameters:
NameDescription
responseType: ChatCompletion

parse_params

parse_params(self, params: dict[str, Any]) -> dict[str, Any]

Loads the parameters for Cerebras API from the passed in parameters and returns a validated set. Checks types, ranges, and sets defaults

Parameters:
NameDescription
paramsType: dict[str, Any]