Documentation
¶
Overview ¶
Package moonshot exposes Moonshot AI chat adapters. NewChat targets its OpenAI-compatible endpoint; NewMessages targets its Anthropic-compatible endpoint.
Index ¶
Constants ¶
const ( OpenAIRequestExtensionKey = "moonshot/openai_request" OpenAIResponseExtensionKey = "moonshot/openai_response" OpenAIStreamChunkExtensionKey = "moonshot/openai_stream_chunk" AnthropicRequestExtensionKey = "moonshot/anthropic_request" AnthropicResponseExtensionKey = "moonshot/anthropic_response" AnthropicStreamEventExtensionKey = "moonshot/anthropic_stream_event" )
Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.
const ( // BaseURL is the domestic OpenAI-compat endpoint. BaseURL = "https://api.moonshot.cn/v1" // BaseURLIntl is the international OpenAI-compat endpoint. BaseURLIntl = "https://api.moonshot.ai/v1" )
OpenAI-compatible endpoints.
const ( // BaseURLAnthropic is the domestic Anthropic-compat endpoint. BaseURLAnthropic = "https://api.moonshot.cn/anthropic" // BaseURLIntlAnthropic is the international Anthropic-compat endpoint. BaseURLIntlAnthropic = "https://api.moonshot.ai/anthropic" )
Anthropic-compatible endpoints. anthropic-sdk-go appends "v1/messages" to the configured base.
const ( ModelK3 = "kimi-k3" ModelK27Code = "kimi-k2.7-code" ModelK27CodeHighSpeed = "kimi-k2.7-code-highspeed" ModelK26 = "kimi-k2.6" ModelK25 = "kimi-k2.5" )
Current Chat model ids. See https://platform.kimi.com/docs/models.
const (
Provider = "Moonshot"
)
Provider is the stable backend name for host-side attribution.
const RequestExtensionKey = "moonshot/request"
Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chat ¶ added in v0.13.0
type Chat = openai.ChatCompletions
Chat implements Moonshot's OpenAI-compatible endpoint.
func NewChat ¶ added in v0.13.0
func NewChat(config ChatConfig) (*Chat, error)
NewChat rejects an invalid provider binding before the first chat call.
type ChatConfig ¶ added in v0.13.0
type ChatConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ChatConfig binds provider access and defaults shared by every chat call.
func (ChatConfig) Validate ¶ added in v0.13.0
func (c ChatConfig) Validate() error
type ChatRequestOptions ¶
type ChatRequestOptions struct {
Thinking *Thinking `json:"thinking,omitempty"`
ReasoningEffort ReasoningEffort `json:"reasoning_effort,omitempty"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
SafetyIdentifier string `json:"safety_identifier,omitempty"`
Partial *bool `json:"partial,omitempty"`
}
ChatRequestOptions contains Kimi Chat Completions fields without a provider-neutral Core equivalent.
func (ChatRequestOptions) ValidateFor ¶
func (c ChatRequestOptions) ValidateFor(model string) error
type Messages ¶ added in v0.13.0
Messages implements Moonshot's Anthropic-compatible endpoint.
func NewMessages ¶ added in v0.13.0
func NewMessages(config MessagesConfig) (*Messages, error)
NewMessages rejects an invalid provider binding before the first Messages call.
type MessagesConfig ¶ added in v0.13.0
type MessagesConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
MessagesConfig binds provider access and defaults shared by every Messages call.
func (MessagesConfig) Validate ¶ added in v0.13.0
func (m MessagesConfig) Validate() error
type ReasoningEffort ¶
type ReasoningEffort string
ReasoningEffort controls Kimi K3 reasoning intensity.
const ( ReasoningEffortLow ReasoningEffort = "low" ReasoningEffortHigh ReasoningEffort = "high" ReasoningEffortMax ReasoningEffort = "max" )
These are the provider values this adapter recognizes.
type Thinking ¶
type Thinking struct {
Type ThinkingType `json:"type"`
Keep ThinkingKeep `json:"keep,omitempty"`
}
Thinking configures Kimi K2.x reasoning.
type ThinkingKeep ¶
type ThinkingKeep string
ThinkingKeep controls preserved thinking for Kimi K2.x models.
const ThinkingKeepAll ThinkingKeep = "all"
ThinkingKeepAll is the only preserved-thinking mode Kimi K2.x accepts. It is a named constant so a caller states the intent rather than the vendor's spelling.
type ThinkingType ¶
type ThinkingType string
ThinkingType controls thinking for Kimi K2.x models.
const ( ThinkingEnabled ThinkingType = "enabled" ThinkingDisabled ThinkingType = "disabled" )
These are the provider values this adapter recognizes.