Skip to content

API Reference

This page is the compact reference. If you are learning the library, start with Getting Started and Architecture first.

PackagePurpose
github.com/Desarso/godanticAgent constructors, model helpers, config builder, session re-exports.
github.com/Desarso/godantic/modelsRequest, response, message, and tool declaration types.
github.com/Desarso/godantic/storesSQLite/Postgres stores and persistence interfaces.
github.com/Desarso/godantic/common_toolsBuilt-in tools and tool declaration helpers.
github.com/Desarso/godantic/sessionsHTTP and WebSocket session internals and interfaces.
func Create_Agent(model Model, tools []models.FunctionDeclaration, memory ...MemoryManager) Agent
func Create_Agent_From_Config(config *WSConfig, tools []models.FunctionDeclaration, memory ...MemoryManager) Agent

Create_Agent is the direct path. Create_Agent_From_Config is useful when model/provider configuration is loaded dynamically.

type Model interface {
Model_Request(models.Model_Request, []models.FunctionDeclaration, []stores.Message) (models.Model_Response, error)
Stream_Model_Request(models.Model_Request, []models.FunctionDeclaration, []stores.Message) (<-chan models.Model_Response, <-chan error)
}
NewGeminiModel(modelName string)
NewOpenRouterModel(modelName string)
NewGroqModel(modelName string)
NewCerebrasModel(modelName string)
NewAnthropicModel(modelName string)

With options:

NewAnthropicModelWithOptions(modelName string, temperature *float64, maxTokens *int, systemPrompt string)
NewOpenRouterModelWithOptions(modelName string, temperature *float64, maxTokens *int, siteURL, siteName string)
NewOpenRouterModelWithBaseURL(modelName, baseURL, apiKeyEnv string, temperature *float64, maxTokens *int)
NewGroqModelWithOptions(modelName string, temperature *float64, maxTokens *int, systemPrompt string)
NewCerebrasModelWithOptions(modelName string, temperature *float64, maxTokens *int, systemPrompt string, topP *float64, seed *int)
type Model_Request struct {
User_Message *User_Message `json:"message,omitempty"`
Tool_Results *[]Tool_Result `json:"tool_results,omitempty"`
Client_ID string `json:"client_id,omitempty"`
Input_Mode string `json:"input_mode,omitempty"`
Language_Code string `json:"language_code,omitempty"`
}
type User_Message struct {
Role string `json:"role"`
Content Content `json:"content"`
}
type User_Part struct {
Text string `json:"text,omitempty"`
InlineData *InlineData `json:"inline_data,omitempty"`
ImageData *ImageData `json:"image_data,omitempty"`
FileData *FileData `json:"file_data,omitempty"`
FunctionResponse *FunctionResponse `json:"function_response,omitempty"`
}
type Model_Response struct {
Parts []Model_Part `json:"parts"`
Warnings []HistoryWarning `json:"warnings,omitempty"`
}
type Model_Part struct {
Text *string `json:"text,omitempty"`
FunctionCall *FunctionCall `json:"functionCall,omitempty"`
Reasoning *string `json:"reasoning,omitempty"`
}
type FunctionCall struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Args map[string]interface{} `json:"args"`
ThoughtSignature string `json:"thoughtSignature,omitempty"`
}
func NewHTTPSession(conversationID string, agent *Agent, store stores.MessageStore) *HTTPSession

Common methods:

RunSingleInteraction(userMessage models.User_Message) (models.Model_Response, error)
RunStreamInteraction(userMessage models.User_Message) (<-chan models.Model_Response, <-chan error)
RunSingleInteractionWithRequest(request models.Model_Request) (models.Model_Response, error)
RunStreamInteractionWithRequest(request models.Model_Request) (<-chan models.Model_Response, <-chan error)
RunSSEInteraction(userMessage models.User_Message, writer SSEWriter, ctx context.Context) error
RunSSEInteractionWithRequest(request models.Model_Request, writer SSEWriter, ctx context.Context) error
GetChatHistory() ([]models.ChatMessageResponse, error)
func NewAgentSession(
sessionID string,
userID string,
conn *websocket.Conn,
agent *Agent,
store stores.MessageStore,
memory MemoryManager,
) *AgentSession

Common methods:

RunInteraction(req models.Model_Request) error
RunInteractionWithContext(ctx context.Context, req models.Model_Request) error
SetTraceStore(traceStore stores.TraceStore)
stores.NewSQLiteStoreSimple(dbPath string)
stores.NewPostgresStoreSimple(dsn string)
stores.NewStore(config *stores.StoreConfig)

Store interface:

type MessageStore interface {
SaveMessage(sessionID, role, messageType string, parts interface{}, functionID string) error
SaveMessageWithUser(sessionID, userID, role, messageType string, parts interface{}, functionID string) error
FetchHistory(sessionID string, limit int) ([]Message, error)
CreateConversation(convoID, userID string) error
ListConversations() ([]string, error)
ListConversationsForUser(userID string) ([]ConversationInfo, error)
Connect() error
Close() error
Ping() error
}
type FunctionDeclaration struct {
Name string
Description string
Parameters Parameters
Callable interface{}
}

Tool registration:

Create_Tool(fn interface{}) (models.FunctionDeclaration, error)
Create_Tools(fns []interface{}) ([]models.FunctionDeclaration, error)

Direct execution:

agent.ExecuteTool(functionName string, functionCallArgs map[string]interface{}, sessionID string) (string, error)
agent.ApproveTool(name string, args map[string]interface{}) (bool, error)

Built-in declaration helpers:

common_tools.DefaultTools()
common_tools.WebSearchTool()
common_tools.WebFetchTool()
common_tools.ReadFileTool()
common_tools.WriteFileTool()
common_tools.EditFileTool()
common_tools.ListDirectoryTool()
common_tools.ShellExecTool()
config := godantic.NewWSConfig().
WithOpenRouter("openai/gpt-4o-mini").
WithSystemPrompt("You are concise and helpful.").
WithSQLiteStore("chat.sqlite").
WithTools([]interface{}{common_tools.Brave_Search}).
WithTemperature(0.2).
WithMaxTokens(2048)

Provider helpers:

WithProvider(provider ModelProvider)
WithOpenRouter(model string)
WithGroq(model string)
WithCerebras(model string)
WithAnthropic(model string)
WithModelName(modelName string)