Documentation
¶
Overview ¶
Package audiocpp provides audio.cpp (audiocpp_server) integration for the gateway. audio.cpp is a local, audio-only inference server: it serves text-to-speech and speech-to-text under OpenAI-shaped /v1/audio paths, and has no chat, Responses, or embeddings surface.
Index ¶
- Variables
- func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
- type Provider
- func (p *Provider) ChatCompletion(_ context.Context, _ *core.ChatRequest) (*core.ChatResponse, error)
- func (p *Provider) CreateSpeech(ctx context.Context, req *core.AudioSpeechRequest) (*core.AudioResponse, error)
- func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
- func (p *Provider) Embeddings(_ context.Context, _ *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
- func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)
- func (p *Provider) ListVoices(ctx context.Context, req *core.AudioVoicesRequest) (*core.AudioVoicesResponse, error)
- func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
- func (p *Provider) Responses(_ context.Context, _ *core.ResponsesRequest) (*core.ResponsesResponse, error)
- func (p *Provider) SetBaseURL(url string)
- func (p *Provider) StreamChatCompletion(_ context.Context, _ *core.ChatRequest) (io.ReadCloser, error)
- func (p *Provider) StreamResponses(_ context.Context, _ *core.ResponsesRequest) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
var Registration = providers.Registration{ Type: "audiocpp", New: New, PassthroughSemanticEnricher: passthroughSemanticEnricher, Discovery: providers.DiscoveryConfig{ RequireBaseURL: true, AllowAPIKeyless: true, }, }
Registration provides factory registration for the audio.cpp provider. audiocpp_server's default port (8080) collides with the gateway's own, so the base URL is required rather than defaulted. The server has no authentication of its own, so the API key is optional and only useful when a reverse proxy in front of it expects a bearer token.
Functions ¶
func New ¶
func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
New creates an audio.cpp provider. The client is rooted at the server root rather than its /v1 prefix: audio.cpp serves /health there, and every other endpoint carries its own /v1 prefix. A base URL configured with a trailing /v1 (the shape every other local-server provider uses) is accepted and trimmed, so both spellings address the same server.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the audio capability and native passthrough against one audiocpp_server. Chat, Responses, and embeddings return invalid_request_error because audio.cpp has no such endpoints.
func (*Provider) ChatCompletion ¶
func (p *Provider) ChatCompletion(_ context.Context, _ *core.ChatRequest) (*core.ChatResponse, error)
ChatCompletion reports that audio.cpp has no chat API.
func (*Provider) CreateSpeech ¶
func (p *Provider) CreateSpeech(ctx context.Context, req *core.AudioSpeechRequest) (*core.AudioResponse, error)
CreateSpeech forwards an OpenAI-compatible text-to-speech request to audio.cpp's POST /v1/audio/speech. The body travels as sent, so the fields audio.cpp adds to the OpenAI shape (voice_ref, reference_text, seed, max_tokens, options, stream_format, ...) reach it unchanged through ExtraFields.
The "voice" a caller sends names an audio.cpp voice preset, cached voice id, or voice-library wav rather than an OpenAI voice, since audio.cpp has no fixed voice set. audio.cpp takes only a string voice, so an OpenAI custom-voice object ({"id": ...}) is sent as its id.
The one field that does not travel is a voice_ref naming a server-side path: see serverPathVoiceRefError.
func (*Provider) CreateTranscription ¶
func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
CreateTranscription implements speech-to-text against audio.cpp's POST /v1/audio/transcriptions as an OpenAI-style multipart upload.
audio.cpp also accepts a JSON body naming a path the server itself can read, and a live route that carries raw PCM with no file at all. Neither is offered here: both let the caller choose what the audio.cpp host reads or how long it holds the model, which being authorized for a model does not cover. They stay on the native passthrough surface, which an operator enables deliberately.
func (*Provider) Embeddings ¶
func (p *Provider) Embeddings(_ context.Context, _ *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
Embeddings reports that audio.cpp has no embeddings API.
func (*Provider) ListModels ¶
ListModels returns the models audiocpp_server was configured with. The gateway can only route the two tasks it has OpenAI endpoints for, so only those carry a mode; the rest stay listed without one, since they are still reachable through native passthrough.
func (*Provider) ListVoices ¶ added in v0.2.4
func (p *Provider) ListVoices(ctx context.Context, req *core.AudioVoicesRequest) (*core.AudioVoicesResponse, error)
ListVoices asks audio.cpp's GET /v1/audio/voices?model=... for the voices a TTS model offers and normalizes the answer.
func (*Provider) Passthrough ¶
func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
Passthrough forwards an audio.cpp-native request. It is what reaches the routes the OpenAI-compatible surface cannot express: /health, /audio/transcriptions/details, /audio/transcriptions/live, /audio/alignments, /audio/voices, and /tasks/*.
func (*Provider) Responses ¶
func (p *Provider) Responses(_ context.Context, _ *core.ResponsesRequest) (*core.ResponsesResponse, error)
Responses reports that audio.cpp has no Responses API.
func (*Provider) SetBaseURL ¶
SetBaseURL allows configuring a custom base URL for the provider.
func (*Provider) StreamChatCompletion ¶
func (p *Provider) StreamChatCompletion(_ context.Context, _ *core.ChatRequest) (io.ReadCloser, error)
StreamChatCompletion reports that audio.cpp has no chat API.
func (*Provider) StreamResponses ¶
func (p *Provider) StreamResponses(_ context.Context, _ *core.ResponsesRequest) (io.ReadCloser, error)
StreamResponses reports that audio.cpp has no Responses API.