MCPcopy Index your code
hub / github.com/github/copilot-sdk / SetModel

Method SetModel

go/session.go:1744–1758  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1742// log.Printf("Failed to set model: %v", err)
1743// }
1744func (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
1760type LogOptions struct {
1761 // Level sets the log severity. Valid values are [rpc.SessionLogLevelInfo] (default),

Callers 5

captureSetModelRequestFunction · 0.95
TestSessionConfigE2EFunction · 0.80
TestSessionRPCE2EFunction · 0.80

Calls 1

SwitchToMethod · 0.80

Tested by 5

captureSetModelRequestFunction · 0.76
TestSessionConfigE2EFunction · 0.64
TestSessionRPCE2EFunction · 0.64