Models API

The models module provides unified interfaces for various LLM providers.

Base Class

Model

class hivetracered.models.base_model.Model[source]

Bases: ABC

Abstract base class for language model implementations. Defines the standard interface for interacting with various LLM providers, supporting both synchronous and asynchronous operations for single requests and batches.

abstractmethod async abatch(prompts)[source]

Send multiple requests to the model asynchronously.

Parameters:

prompts (List[str | List[Dict[str, str]]]) – A list of prompts to send to the model

Return type:

List[dict]

Returns:

List of response dictionaries in the same order as the input prompts

abstractmethod async ainvoke(prompt)[source]

Send a single request to the model asynchronously.

Parameters:

prompt (str | List[Dict[str, str]]) – A string or list of messages to send to the model

Return type:

dict

Returns:

Dictionary containing the model’s response with at least a ‘content’ key

abstractmethod batch(prompts)[source]

Send multiple requests to the model synchronously.

Parameters:

prompts (List[str | List[Dict[str, str]]]) – A list of prompts to send to the model

Return type:

List[dict]

Returns:

List of response dictionaries in the same order as the input prompts

get_params()[source]

Get the parameters of the model.

Return type:

dict

Returns:

Dictionary containing the model’s configuration parameters

abstractmethod invoke(prompt)[source]

Send a single request to the model synchronously.

Parameters:

prompt (str | List[Dict[str, str]]) – A string or list of messages to send to the model

Return type:

dict

Returns:

Dictionary containing the model’s response with at least a ‘content’ key

is_answer_blocked(answer)[source]

Check if the answer is blocked by model’s safety guardrails.

Parameters:

answer (dict) – The model response dictionary to check

Return type:

bool

Returns:

Boolean indicating if the response was blocked

model_name: str
abstractmethod async stream_abatch(prompts)[source]

Send multiple requests to the model asynchronously and yield results as they complete.

Parameters:

prompts (List[str | List[Dict[str, str]]]) – A list of prompts to send to the model

Yields:

Response dictionaries as they become available, not necessarily in input order

Model Implementations

OpenAI Models

class hivetracered.models.openai_model.OpenAIModel(model='gpt-4.1-nano', base_url='https://api.openai.com/v1', max_concurrency=None, batch_size=None, rpm=300, api_key=None, max_retries=3, **kwargs)[source]

Bases: LangchainModel

OpenAI-compatible language model implementation using the LangChain integration. Provides a standardized interface to OpenAI’s API (or any OpenAI-compatible endpoint) with rate limiting support and both synchronous and asynchronous processing capabilities.

__init__(model='gpt-4.1-nano', base_url='https://api.openai.com/v1', max_concurrency=None, batch_size=None, rpm=300, api_key=None, max_retries=3, **kwargs)[source]

Initialize the OpenAI model client with the specified configuration.

Parameters:
  • model (str) – Model identifier (e.g., “gpt-4”, “gpt-3.5-turbo”, or any model name for compatible APIs)

  • base_url (str) – API base URL (default: “https://api.openai.com/v1”). Override for OpenAI-compatible endpoints.

  • max_concurrency (int | None) – Maximum number of concurrent requests (replaces batch_size)

  • batch_size (int | None) – (Deprecated) Use max_concurrency instead. Will be removed in v2.0.0

  • rpm (int) – Rate limit in requests per minute

  • api_key (str | None) – API key; defaults to OPENAI_API_KEY env var

  • max_retries (int) – Maximum number of retry attempts on transient errors (default: 3)

  • **kwargs – Additional parameters to pass to the ChatOpenAI constructor

GigaChat Models

class hivetracered.models.gigachat_model.GigaChatModel(model='GigaChat', max_concurrency=None, batch_size=None, scope=None, credentials=None, verify_ssl_certs=False, max_retries=3, **kwargs)[source]

Bases: LangchainModel

GigaChat language model implementation using LangChain integration. Provides standardized access to Sber’s GigaChat models with support for both synchronous and asynchronous request processing.

__init__(model='GigaChat', max_concurrency=None, batch_size=None, scope=None, credentials=None, verify_ssl_certs=False, max_retries=3, **kwargs)[source]

Initialize the GigaChat model client with the specified configuration.

Parameters:
  • model (str) – GigaChat model variant (e.g., “GigaChat”, “GigaChat-Pro”)

  • max_concurrency (int | None) – Maximum number of concurrent requests (replaces batch_size)

  • batch_size (int | None) – (Deprecated) Use max_concurrency instead. Will be removed in v2.0.0

  • scope (str | None) – API scope for authorization (from env or explicit)

  • credentials (str | None) – API credentials for authentication (from env or explicit)

  • verify_ssl_certs (bool) – Whether to verify SSL certificates for API connections

  • max_retries (int) – Maximum number of retry attempts on transient errors (default: 3)

  • **kwargs – Additional parameters for model configuration: - profanity_check: Whether to enable profanity filtering - temperature: Sampling temperature (lower = more deterministic) - max_tokens: Maximum tokens in generated responses - top_p: Top-p sampling parameter for response diversity

Yandex Models

Google Gemini Models

Sber Cloud Models

OpenRouter Models

Web-Based Models (Browser Automation)

Web Model Base Class

Mistral Web Model

Utilities

Web Action Recorder

See Also