task.llm for making language model calls. Guild resolves the provider and model from the workspace owner’s LLM settings — your agent code doesn’t need to specify them.
Basic usage
Structured generation
Pass a Zod schema to get typed, validated output:Best practices
- Cache results. Store the return value of
generateText()in a variable if you need it more than once. Each call costs tokens. - Be specific in prompts. Clear, detailed prompts produce better results and reduce the need for follow-up calls.
- Use schemas for structured data. When you need specific fields, pass a schema rather than parsing free-form text.
- Keep prompts focused. One clear task per call is better than a complex multi-part prompt.
Configuration
The provider and model are resolved at runtime from the workspace owner’s LLM settings, not in agent code. For a workspace owned by your user account, use Settings > LLM Settings. For an organization workspace, organization admins configure Settings > LLM Settings on the organization. This means:- Your agent code does not include API keys or provider names
- Changing LLM settings in the console updates behavior without redeploying agents
- Workspaces with different owners can use different LLM configuration with the same agent code