Skip to navigation

Model SDK Adapters

AnthropicAdapter and GeminiAdapter, which run a manual tool loop against a provider SDK

AnthropicAdapter and GeminiAdapter call a model provider’s SDK directly and run the tool loop themselves. Use them when your agent is a prompt plus Band’s tools, with no framework in between. Both follow the shared adapter construction rules and take the feature keywords.

AnthropicAdapter

Adapter for the Anthropic SDK with a manual tool loop.

from band.adapters import AnthropicAdapter, AnthropicAdapterConfig
adapter = AnthropicAdapter(
config: AnthropicAdapterConfig | None = None,
*,
history_converter: AnthropicHistoryConverter | None = None,
additional_tools: list[CustomToolDef] | None = None,
**features: Unpack[FeatureKwargs],
)
AnthropicAdapterConfig fieldTypeDefaultDescription
modelstr"claude-sonnet-5-5"Anthropic model ID
provider_keystr | NoneNoneAnthropic API key; the Anthropic client reads ANTHROPIC_API_KEY when unset
system_promptstr | NoneNoneComplete system prompt, sent verbatim. When set, custom_section, include_base_instructions, and the capability sections are ignored
custom_sectionstr""Additional instructions appended to the Band system prompt
include_base_instructionsboolTrueInclude the Band platform instructions in the system prompt
max_tokensint4096Maximum response tokens per API call; must be greater than 0
from band.adapters import AnthropicAdapter, AnthropicAdapterConfig
adapter = AnthropicAdapter(
AnthropicAdapterConfig(custom_section="Answer in one paragraph."),
)

Emits TOOL_CALLS and USAGE. Since band-sdk 6.0.0 the tool loop ends a turn after a successful band_no_reply call whose sibling tool calls also succeeded, without sending the model another request. api_key and prompt are not fields; passing either raises ValidationError (Extra inputs are not permitted). See Anthropic SDK for a worked example.

GeminiAdapter

Adapter for the Google Gen AI SDK with a manual tool loop.

from band.adapters import GeminiAdapter, GeminiAdapterConfig
adapter = GeminiAdapter(
config: GeminiAdapterConfig | None = None,
*,
history_converter: GeminiHistoryConverter | None = None,
additional_tools: list[CustomToolDef] | None = None,
**features: Unpack[FeatureKwargs],
)
GeminiAdapterConfig fieldTypeDefaultDescription
modelstr"gemini-3.8-flash"Gemini model name
provider_keystr | NoneNoneGemini API key; without it, the Google Gen AI client reads GOOGLE_API_KEY or GEMINI_API_KEY, or uses Vertex AI
system_promptstr | NoneNoneComplete system prompt, sent verbatim. When set, custom_section, include_base_instructions, and the capability sections are ignored
custom_sectionstr""Additional instructions appended to the Band system prompt
include_base_instructionsboolTrueInclude the Band platform instructions in the system prompt
max_output_tokensint | NoneNoneOutput token cap per call; None uses the model default
temperaturefloat | NoneNoneSampling temperature; None uses the model default
max_tool_roundsint20Model calls a single turn may make before it fails with Exceeded max tool rounds (<n>) in room <room_id>; tool sequence: ...
max_retriesint2Retries of a call after a transient server or transport error
retry_base_delay_sfloat1.0First retry delay in seconds, doubled on each further retry
max_history_messagesint200Room history entries kept per room; older ones are trimmed
from band.adapters import GeminiAdapter, GeminiAdapterConfig
adapter = GeminiAdapter(GeminiAdapterConfig(temperature=0.2))

Emits TOOL_CALLS and USAGE. Without a key, client construction fails with Gemini client initialization failed. Either set GOOGLE_API_KEY / GEMINI_API_KEY, or enable Vertex AI mode (GOOGLE_GENAI_USE_VERTEXAI=true + GOOGLE_CLOUD_PROJECT). A failed model run that Gemini returns as data, such as a safety finish_reason or a blocked prompt, is reported to the room as a provider failure with its coarse code; the detail goes only to the agent log. See Gemini for a worked example.