Skip to main content
Use LlmModel and Prompt to control which model your agent uses, how it generates responses, and what instructions it follows.

Prerequisites

  • AgenticAI Core SDK installed and configured.
  • A valid connection configured for your LLM provider (OpenAI, Anthropic, or Azure OpenAI).

Configure the LLM model

Basic configuration

Builder pattern

Use LlmModelBuilder and LlmModelConfigBuilder for a fluent configuration style:

Supported providers

OpenAI

Anthropic (Claude)

Azure OpenAI

LLM parameters

Temperature (0.0–2.0)

Controls output randomness. Lower values produce more predictable responses; higher values produce more varied ones.

Max tokens

Sets the maximum number of tokens the model generates per response.

Top P (0.0–1.0)

Nucleus sampling parameter — controls the token pool the model samples from.
  • 0.1–0.5: Focused, less diverse sampling.
  • 0.6–0.9: Balanced diversity.
  • 0.95–1.0: Maximum diversity.

Penalties (−2.0 to 2.0)

Reduce repetition in responses:
  • frequency_penalty: Penalizes tokens that appear frequently in the output.
  • presence_penalty: Encourages the model to introduce new topics.

Configure prompts

System prompt

Sets the base role for the agent:

Custom prompt

Provides detailed instructions and context beyond the system role:

Instructions

Pass structured rules as a list. Use instructions for compliance, tone, and handling guidelines — especially for sensitive domains:
Security guidance: Always include a security instruction block for apps that handle sensitive data:
Voice agent guidance: For voice or audio agents, add a speaking style instruction:

Template variables

Prompts support runtime variable substitution using {{variable}} syntax:

Orchestrator prompts

For supervisor or orchestrator agents, define routing rules in the custom prompt:

Task-specific configurations

Match your LlmModelConfig to the nature of the agent’s task: Factual tasks — use low temperature for consistent, accurate responses:
Creative tasks — use higher temperature for varied output:
Balanced (general-purpose):

Optimization tips

Cost
  • Use smaller models for simple, repetitive tasks.
  • Set max_tokens to the minimum needed for the expected response length.
  • Set max_iterations to limit unnecessary tool calls.
  • Configure reasonable timeouts to avoid runaway sessions.
Quality
  • Use the latest model versions for your provider.
  • Increase max_tokens when detailed responses are required.
  • Lower temperature for tasks that require consistency.
  • Increase max_iterations for complex multi-step workflows.