SetModel changes the model for this session. The new model takes effect for the next message. Conversation history is preserved. Example: if err := session.SetModel(context.Background(), "gpt-4.1", nil); err != nil { log.Printf("Failed to set model: %v", err) } if err := session.SetModel(c
(ctx context.Context, model string, opts *SetModelOptions)
| 1742 | // log.Printf("Failed to set model: %v", err) |
| 1743 | // } |
| 1744 | func (s *Session) SetModel(ctx context.Context, model string, opts *SetModelOptions) error { |
| 1745 | params := &rpc.ModelSwitchToRequest{ModelID: model} |
| 1746 | if opts != nil { |
| 1747 | params.ReasoningEffort = opts.ReasoningEffort |
| 1748 | params.ReasoningSummary = opts.ReasoningSummary |
| 1749 | params.ContextTier = opts.ContextTier |
| 1750 | params.ModelCapabilities = opts.ModelCapabilities |
| 1751 | } |
| 1752 | _, err := s.RPC.Model.SwitchTo(ctx, params) |
| 1753 | if err != nil { |
| 1754 | return fmt.Errorf("failed to set model: %w", err) |
| 1755 | } |
| 1756 | |
| 1757 | return nil |
| 1758 | } |
| 1759 | |
| 1760 | type LogOptions struct { |
| 1761 | // Level sets the log severity. Valid values are [rpc.SessionLogLevelInfo] (default), |