Call pi.setModel() inside before_agent_start:
pi.on('before_agent_start', async (_event, ctx) => {
  if (ctx.external?.conversationType === 'dm') {
    const accepted = await pi.setModel({
      provider: 'openai',
      modelId: 'gpt-5.2',
      thinkingLevel: 'medium',
    });

    if (!accepted) {
      throw new Error('The requested model selection is invalid.');
    }
  }
});

Selection

FieldRequirement
providerNon-empty provider identifier
modelIdNon-empty model identifier
thinkingLevelOptional supported thinking level
Supported thinking values are off, minimal, low, medium, high, xhigh, and max. The method resolves to true for a structurally valid selection and false for an invalid one. The selected provider/model must also be available to the hosted runtime; availability is checked when Salambo applies it.

Lifecycle

The hosted runtime applies model selection from before_agent_start. Do not call setModel() unconditionally at module initialization: manifest discovery exposes registration methods, not runtime mutation methods. Salambo records and restores the active model and thinking level on durable follow-up turns.