together

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: BSD-2-Clause Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package together provides Together AI's OpenAI-compatible LLM service and its streaming speech-to-text and text-to-speech services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMConfig added in v0.3.0

type LLMConfig struct {
	chat.LLMConfig
	// Reasoning is Together's reasoning toggle, for the models that support one,
	// such as {"enabled": false}. A reasoning model such as GLM runs a reasoning
	// pass before every answer, which delays the first spoken token. Nil leaves
	// the choice to the model's own default.
	Reasoning map[string]any
	// ReasoningEffort is how much the model reasons before answering. Values
	// vary by model: "low", "medium" and "high" are common, zai-org/GLM-5.3 also
	// takes "max", and some models map a value they do not support onto one they
	// do. Other strings are passed through as given. GLM-5.3 ignores Reasoning,
	// but "low" still shortens its reasoning pass. Empty leaves Together's
	// per-model default.
	ReasoningEffort string
}

LLMConfig configures a Together AI LLM service: everything the OpenAI-compatible endpoint takes, plus the reasoning controls Together adds to it.

func (LLMConfig) Validate added in v0.3.0

func (c LLMConfig) Validate() error

Validate reports whether the configuration is usable.

type LLMService added in v1.0.0

type LLMService struct {
	*chat.LLMService
}

LLMService is the Together AI LLM service NewLLM builds.

func NewLLM

func NewLLM(cfg LLMConfig) *LLMService

NewLLM builds a Together AI LLM service.

type LLMSettings added in v1.2.0

type LLMSettings struct {
	chat.LLMSettings
	// Reasoning is Together's reasoning toggle. See LLMConfig.Reasoning.
	Reasoning settings.Opt[map[string]any] `settings:"reasoning"`
	// ReasoningEffort is how much the model reasons before answering. See
	// LLMConfig.ReasoningEffort.
	ReasoningEffort settings.Opt[string] `settings:"reasoning_effort"`
}

LLMSettings is the Together AI LLM configuration that can change while the pipeline runs, through an LLMUpdateSettingsFrame: the OpenAI-compatible settings, plus the reasoning controls. Every request is built from it.

type STTConfig added in v0.0.4

type STTConfig struct {
	// APIKey is the Together AI API key. Required.
	APIKey string `validate:"required"`
	// BaseURL overrides the realtime WebSocket base; empty uses the hosted endpoint.
	BaseURL string
	// Model is the transcription model; empty uses a default.
	Model string
	// Language hints the spoken language; reported on results. The zero value
	// leaves it unknown.
	Language language.Language
	// SampleRate is the input audio sample rate; 0 uses the transport's rate.
	SampleRate int
	// TurnDetection selects server-side endpointing; empty uses "server_vad".
	TurnDetection string

	// TTFSP99 overrides the measured transcript latency the turn strategies
	// size their wait by; nil uses stt.TogetherTTFSP99, and zero means no wait.
	TTFSP99 *time.Duration
	// Websocket configures the connection: whether and how it reconnects, and
	// how long it waits on a peer that has stopped answering.
	Websocket wsservice.Options
}

STTConfig configures the Together AI streaming STT service, which uses an OpenAI-compatible realtime transcription WebSocket.

func (STTConfig) Validate added in v0.0.4

func (c STTConfig) Validate() error

Validate reports whether the configuration is usable.

type STTService added in v1.0.0

type STTService struct {
	*stt.StreamService
}

STTService is the Together AI speech-to-text service NewSTT builds.

func NewSTT added in v0.0.4

func NewSTT(cfg STTConfig) *STTService

NewSTT builds a Together AI streaming STT service.

type TTSConfig added in v0.0.4

type TTSConfig struct {
	// APIKey is the Together AI API key. Required.
	APIKey string `validate:"required"`
	// URL overrides the TTS WebSocket endpoint; empty uses the hosted endpoint.
	URL string
	// Model is the TTS model; empty uses a default.
	Model string
	// Voice is the voice id; empty uses a default.
	Voice string
	// Language for synthesis; the zero value uses English. Sent as the ISO 639-1
	// or lowercase locale code Together accepts.
	Language language.Language
	// MaxPartialLength caps the partial text length for streaming; nil omits it.
	MaxPartialLength *int
	// ExtraParams are model-specific synthesis options sent with the session
	// setup, such as "pronunciation_dict", a list of "<source>/<replacement>"
	// entries; nil sends none.
	ExtraParams map[string]any
	// Websocket configures the connection: whether and how it reconnects, and
	// how long it waits on a peer that has stopped answering.
	Websocket wsservice.Options
}

TTSConfig configures the Together AI streaming TTS service, which streams 24 kHz mono PCM over an OpenAI-compatible realtime WebSocket.

func (TTSConfig) Validate added in v0.0.4

func (c TTSConfig) Validate() error

Validate reports whether the configuration is usable.

type TTSService added in v1.0.0

type TTSService struct {
	*tts.Base
}

TTSService is the Together AI text-to-speech service NewTTS builds.

func NewTTS added in v0.0.4

func NewTTS(cfg TTSConfig) *TTSService

NewTTS builds a Together AI streaming TTS service.

It holds one connection open for the call, opened when the pipeline starts. When it drops it is restored with backoff, and when that keeps failing the service reports a permanent error and becomes unusable. Together's audio names no request, so it is labeled with the context playing, and the next request's frames are held until this one's audio has played.

type TTSSettings added in v0.6.0

type TTSSettings struct {
	settings.TTS

	// MaxPartialLength caps the partial text length for streaming.
	MaxPartialLength settings.Opt[int] `settings:"max_partial_length"`
	// ExtraParams are model-specific synthesis options sent with the session
	// setup, such as "pronunciation_dict".
	ExtraParams settings.Opt[map[string]any] `settings:"extra_params"`
}

TTSSettings is the part of the synthesis configuration that can change while the pipeline runs.

The model, the voice, the language and the partial length are read from the URL a connection is opened on, and the options are sent once it is open, so any change reconnects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL