ChatBot.provider_model()

Set provider and model using a single string (e.g., “openai:gpt-4o”).

Usage

Source

ChatBot.provider_model(provider_model)

This method provides a convenient way to configure both the AI provider and model in a single call using a colon-separated format. This is especially useful when you want to explicitly specify the provider or when working with models from different providers that might have similar names.

Parameters

provider_model: str
String in the format "provider:model" (e.g., "openai:gpt-4o", "anthropic:claude-3-opus"). If only a model name is provided without a colon, defaults to OpenAI provider.

Returns

ChatBot
Returns self for method chaining, allowing you to configure multiple parameters in a single fluent expression.

Raises

ValueError
If the provider_model= string is empty, None, or improperly formatted.

Examples

Using explicit provider and model combinations

import talk_box as tb

# OpenAI models
openai_bot = tb.ChatBot().provider_model("openai:gpt-4o")

# Anthropic models
anthropic_bot = tb.ChatBot().provider_model("anthropic:claude-opus-4-7")

# Google models
google_bot = tb.ChatBot().provider_model("google:gemini-pro")

# Default to OpenAI if no provider specified
default_bot = tb.ChatBot().provider_model("gpt-4-turbo")

Method chaining with provider_model

# Complete configuration with explicit provider
bot = (
    ChatBot()
    .provider_model("anthropic:claude-opus-4-7")
    .preset("technical_advisor")
    .temperature(0.2)
    .max_tokens(2000)
)

Notes

Provider Authentication: ensure appropriate API keys are set in environment variables for the specified provider (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY).

Provider Detection: when only a model name is provided, the system defaults to OpenAI. For other providers, always specify the provider explicitly.

See Also

  • model(): Set just the model name (uses default provider detection)
  • preset(): Apply behavior presets that work well with specific provider/model combinations