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.
LLM usage is subject to per-execution budgets: request payload size, call count, and token count. Exceeding a budget fails the call with a
429 Too Many Requests error. See Execution limits.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.
LLM preferences
UsellmPreferences to express an ordered list of LLM provider/model preferences for a generateText call. Guild honors this list only when the account brings its own keys (BYOK) and server-side model selection is enabled; otherwise the server ignores it and selects the model from policy.
model to let the server choose a model from the matching policy.
Each entry is an LLMPreference object:
llmAgent also accepts llmPreferences with the same semantics. See LLM agents.
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
Unified LLM proxy
When your agent code already targets the OpenAI API — for example, code running inside a Docker environment managed withtask.env — you can point it at the runtime’s built-in LLM proxy instead of a provider directly. Guild routes each request to the provider configured in the workspace’s LLM settings and translates the request and response as needed. Your code targets one interface regardless of the active provider.
The proxy endpoint accepts the OpenAI chat completions format and is available inside the agent task environment at the path /runtime/services/llm/chat/completions.
Provider support
Developer role
OpenAI’sdeveloper role messages are automatically folded into the system prompt. You do not need to adjust your message structure when switching providers.