Documentation
¶
Overview ¶
Package zai provides Z.ai API integration for the LLM gateway.
Index ¶
- Variables
- func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
- type Provider
- func (p *Provider) RealtimeTarget(ctx context.Context, req *core.RealtimeRequest) (*core.RealtimeTarget, error)
- func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
- func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
var Registration = providers.Registration{ Type: "zai", New: New, PassthroughSemanticEnricher: passthroughSemanticEnricher, Discovery: providers.DiscoveryConfig{ DefaultBaseURL: defaultBaseURL, }, MCPServers: mcpServers, }
Registration provides factory registration for the Z.ai provider.
Functions ¶
func New ¶
func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
New creates a new Z.ai provider.
Types ¶
type Provider ¶
type Provider struct {
*openai.ChatCompatible
// contains filtered or unexported fields
}
Provider implements the core.Provider interface for Z.ai. keys is retained to inject auth on the GLM-Realtime websocket target.
func (*Provider) RealtimeTarget ¶
func (p *Provider) RealtimeTarget(ctx context.Context, req *core.RealtimeRequest) (*core.RealtimeTarget, error)
RealtimeTarget implements core.RealtimeProvider for Z.ai / Zhipu GLM-Realtime, whose core event schema mirrors OpenAI's Realtime API. The host (region) comes from the configured base URL while the path is pinned to realtimePath so chat base variants like the Coding Plan endpoint still resolve correctly. Bearer auth is injected here and must never be logged.
func (*Provider) StreamChatCompletion ¶ added in v0.2.7
func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
StreamChatCompletion returns Z.ai's SSE stream with its own finish_reason values mapped onto the OpenAI ones.
func (*Provider) StreamResponses ¶ added in v0.2.7
func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
StreamResponses streams a Responses API request through chat-completions translation, picking up the StreamChatCompletion override.