llm
Together.ai LLM service implementation using OpenAI-compatible interface.
- class pipecat.services.together.llm.TogetherLLMSettings(model: str | None | NotGiven = <factory>, extra: dict[str, Any]=<factory>, system_instruction: str | None | NotGiven = <factory>, temperature: float | None | NotGiven | NotGiven = <factory>, max_tokens: int | None | NotGiven | NotGiven = <factory>, top_p: float | None | NotGiven | NotGiven = <factory>, top_k: int | None | NotGiven = <factory>, frequency_penalty: float | None | NotGiven | NotGiven = <factory>, presence_penalty: float | None | NotGiven | NotGiven = <factory>, seed: int | None | NotGiven | NotGiven = <factory>, filter_incomplete_user_turns: bool | None | NotGiven = <factory>, user_turn_completion_config: UserTurnCompletionConfig | None | NotGiven = <factory>, use_provider_thinking_default: bool | NotGiven = <factory>, max_completion_tokens: int | None | NotGiven | NotGiven = <factory>, reasoning: dict[str, ~typing.Any] | None | ~pipecat.utils.types.NotGiven=<factory>, reasoning_effort: Literal['low', 'medium', 'high', 'max'] | str | None | ~pipecat.utils.types.NotGiven=<factory>)[source]
Bases:
OpenAILLMSettingsSettings for TogetherLLMService.
- Parameters:
reasoning – Together’s reasoning toggle, for the models that support one, e.g.
{"enabled": False}. A reasoning model such as GLM runs a reasoning pass before every answer, which delays the first spoken token.Noneleaves the choice to the model’s own default.reasoning_effort – How much the model reasons before answering. Values vary by model: “low”, “medium” and “high” are common,
zai-org/GLM-5.3also takes “max”, and some models map a value they don’t support onto one they do. Other strings are passed through as-is. GLM-5.3 ignoresreasoning, but “low” still shortens its reasoning pass. When unset, Together’s per-model default applies.
- class pipecat.services.together.llm.TogetherLLMService(*, api_key: str, base_url: str = 'https://api.together.xyz/v1', model: str | None = None, settings: TogetherLLMSettings | None = None, **kwargs)[source]
Bases:
OpenAILLMServiceA service for interacting with Together.ai’s API using the OpenAI-compatible interface.
This service extends OpenAILLMService to connect to Together.ai’s API endpoint while maintaining full compatibility with OpenAI’s interface and functionality.
- supports_developer_role: bool = False
Whether this service’s API supports the “developer” message role.
OpenAI’s native API supports it, but some OpenAI-compatible services (e.g. Cerebras) do not. Subclasses that don’t support it should set this to
False, which causes the adapter to convert “developer” messages to “user” messages before sending them to the API.
- Settings
alias of
TogetherLLMSettings
- __init__(*, api_key: str, base_url: str = 'https://api.together.xyz/v1', model: str | None = None, settings: TogetherLLMSettings | None = None, **kwargs)[source]
Initialize Together.ai LLM service.
- Parameters:
api_key – The API key for accessing Together.ai’s API.
base_url – The base URL for Together.ai API. Defaults to “https://api.together.xyz/v1”.
model –
The model identifier to use. Defaults to “zai-org/GLM-5.2”.
Deprecated since version 0.0.105: Use
settings=TogetherLLMService.Settings(model=...)instead. Will be removed in 2.0.0.settings – Runtime-updatable settings. When provided alongside deprecated parameters,
settingsvalues take precedence.**kwargs – Additional keyword arguments passed to OpenAILLMService.
- create_client(api_key=None, base_url=None, **kwargs)[source]
Create OpenAI-compatible client for Together.ai API endpoint.
- Parameters:
api_key – The API key to use for the client. If None, uses instance api_key.
base_url – The base URL for the API. If None, uses instance base_url.
**kwargs – Additional keyword arguments passed to the parent create_client method.
- Returns:
An OpenAI-compatible client configured for Together.ai’s API.
- build_chat_completion_params(params_from_context: OpenAILLMInvocationParams) dict[str, Any][source]
Build parameters for a Together.ai chat completion request.
- Parameters:
params_from_context – Parameters, derived from the LLM context, to use for the chat completion. Contains messages, tools, and tool choice.
- Returns:
Dictionary of parameters for the chat completion request.