Documentation
¶
Index ¶
- type CacheControl
- type ChatCompletionChoice
- type ChatCompletionMessage
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatCompletionStreamChoice
- type ChatCompletionStreamResponse
- type FunctionDefinition
- type Items
- type OpenAIClient
- type OpenRouterReasoning
- type ProviderStyle
- type ReasoningDetail
- type Tool
- type ToolCall
- type ToolParameter
- type ToolParameters
- type ZAIThinking
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheControl ¶
type CacheControl struct {
Type string `json:"type"`
}
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
Message ChatCompletionMessage `json:"message"`
}
type ChatCompletionMessage ¶
type ChatCompletionMessage struct {
Role string `json:"role"`
Content any `json:"content,omitempty"`
Reasoning *string `json:"reasoning,omitempty"` // OpenRouter
ReasoningContent *string `json:"reasoning_content,omitempty"` // Deepseek, llama-server
ReasoningDetails json.RawMessage `json:"reasoning_details,omitempty"` // OpenRouter preserved thinking
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
Messages []ChatCompletionMessage `json:"messages"`
N int `json:"n"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice string `json:"tool_choice,omitempty"`
Stream bool `json:"stream,omitempty"`
// Reasoning config. TBD: handle for mulitple providers using the same field
Reasoning *OpenRouterReasoning `json:"reasoning,omitempty"`
// CacheControl for OpenRouter
CacheControl *CacheControl `json:"cache_control,omitempty"`
// Thinking config for ZAI
Thinking *ZAIThinking `json:"thinking,omitempty"`
}
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
Choices []ChatCompletionChoice `json:"choices"`
}
type ChatCompletionStreamChoice ¶
type ChatCompletionStreamChoice struct {
Delta ChatCompletionMessage `json:"delta"`
}
type ChatCompletionStreamResponse ¶
type ChatCompletionStreamResponse struct {
Choices []ChatCompletionStreamChoice `json:"choices"`
}
type FunctionDefinition ¶
type FunctionDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters ToolParameters `json:"parameters"`
Arguments string `json:"arguments,omitempty"`
}
type OpenAIClient ¶
func (*OpenAIClient) CreateChatCompletion ¶
func (c *OpenAIClient) CreateChatCompletion( ctx context.Context, params api.RequestParameters, messages []api.Message, ) (*api.Message, error)
func (*OpenAIClient) CreateChatCompletionStream ¶
type OpenRouterReasoning ¶
type OpenRouterReasoning struct {
Effort api.ReasoningEffort `json:"effort,omitempty"` // "xhigh", "high", "medium", "low", "minimal", "none"
Summary ReasoningDetail `json:"summary,omitempty"`
}
type ProviderStyle ¶
type ProviderStyle string
ProviderStyle distinguishes OpenAI-compatible API variants.
const ( StyleOpenAI ProviderStyle = "openai" StyleOpenRouter ProviderStyle = "openrouter" StyleZAI ProviderStyle = "zai" )
type ReasoningDetail ¶
type ReasoningDetail string
const ( Auto ReasoningDetail = "auto" Concise ReasoningDetail = "concise" Detailed ReasoningDetail = "detailed" )
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function FunctionDefinition `json:"function"`
}
type ToolCall ¶
type ToolCall struct {
Type string `json:"type"`
ID string `json:"id"`
Index *int `json:"index,omitempty"`
Function FunctionDefinition `json:"function"`
}
type ToolParameter ¶
type ToolParameters ¶
type ToolParameters struct {
Type string `json:"type"`
Properties map[string]ToolParameter `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
type ZAIThinking ¶
type ZAIThinking struct {
ClearThinking bool `json:"clear_thinking"`
}
Click to show internal directories.
Click to hide internal directories.