BlackBoxModel provides a standardized interface for interacting with models hosted via APIs like OpenAI, Anthropic, and Together.ai. This class handles authentication, retry logic, and batch processing for efficient model querying.
Constructor
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | string | (Required) | Name of the model (e.g., “gpt-4o”, “claude-3-7-sonnet-20250219”) |
system_prompt | string | None | Default system prompt to use for all queries |
max_retries | int | 5 | Maximum number of retry attempts for failed queries |
retry_delay | float | 10.0 | Delay in seconds between retry attempts |
Methods
query
Sends a prompt to the model and retrieves the generated response.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt | string | (Required) | The text prompt to send to the model |
system_prompt | string | None | System prompt for this specific query |
temperature | float | 0 | Controls randomness (0.0 = deterministic, 1.0 = creative) |
max_tokens | int | 2048 | Maximum number of tokens to generate |
message_history | List[Dict] | [] | Message history for chat context |
Returns
A string containing the model’s response.query_parallel
Sends multiple prompts to the model in parallel for efficiency.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
prompts | List[string] | (Required) | List of text prompts to send to the model |
max_threads | int | 50 | Maximum number of parallel threads to use |
show_progress | bool | True | Whether to display a progress bar |
system_prompt | string | None | System prompt for all queries |
temperature | float | 0 | Controls randomness |
max_tokens | int | 2048 | Maximum number of tokens to generate |
message_history | List[Dict] | [] | Message history for chat context |
Returns
A list of strings containing the model’s responses in the same order as the input prompts.embed
Generates embeddings (vector representations) for text.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string or List[string] | (Required) | Text to generate embeddings for |
batch_size | int | 100 | Maximum batch size for processing |
Returns
A list of float values (embedding vector) if a single text is provided, or a list of embedding vectors (list of lists) if multiple texts are provided.embed_parallel
Generates embeddings for multiple texts in parallel.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
texts | List[string] | (Required) | List of texts to generate embeddings for |
batch_size | int | 100 | Maximum batch size for processing |
max_threads | int | 10 | Maximum number of parallel threads to use |
show_progress | bool | True | Whether to display a progress bar |
Returns
A list of embedding vectors (list of lists of float values), one for each input text.Supported Models
TheBlackBoxModel class automatically determines the appropriate API to use based on the model name:
OpenAI Models
- GPT-4o, GPT-4o-mini, GPT-4-turbo
- GPT-4.5-preview-2025-02-27
- GPT-4-0125-preview, GPT-4-0613
- GPT-3.5-turbo
- o1, o1-mini, o3-mini, o3-mini-2025-01-31
- Embedding models: text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002
Anthropic Models
- claude-3-7-sonnet-20250219
- claude-3-5-sonnet-20241022, claude-3-5-sonnet-20240620
- claude-3-5-haiku-20241022
- claude-3-sonnet-20240229
Together.ai Hosted Models
- meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo
- meta-llama/Llama-3.3-70B-Instruct-Turbo
- meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo
- mistralai/Mistral-Small-24B-Instruct-2501
- mistralai/Mixtral-8x22B-Instruct-v0.1
- deepseek-ai/DeepSeek-R1, deepseek-ai/DeepSeek-R1-Distill-Llama-70B
- databricks/dbrx-instruct
- Qwen/Qwen2.5-7B-Instruct-Turbo
- google/gemma-2-27b-it
Error Handling
The BlackBoxModel implements robust error handling:- Automatic retries for temporary API failures
- Logging of error details for debugging
- Graceful degradation for rate limiting

