---
title: "Integrating LLMs"
description: "Use Large Language Models in your workflows for smart processing and decision-making"
---

## Integration Patterns

### Using Agents 

Best for autonomous AI assistants that need to reason, use tools and maintain conversation context.

```python
from timbal import Agent, Workflow

agent = Agent(
    name="summarizer",
    model="openai/gpt-4o-mini",
    system_prompt="Summarize text in 2-3 sentences."
)

workflow = (
    Workflow(name="text_processor")
    .step(agent)
)
```

### Using `llm_router` Tools

Best for single LLM calls with full parameter control.

```python highlight={6}
from timbal import Tool, Workflow
from timbal.core.llm_router import llm_router

llm_tool = Tool(
    name="summarizer",
    handler=llm_router,
    default_params={
        "model": "openai/gpt-4o-mini",
        "system_prompt": "Summarize text in 2-3 sentences."
    }
)

workflow = (
    Workflow(name="text_processor")
    .step(llm_tool)
)
```

## Smart Workflows: Conditional Processing

Let AI decide which workflow steps to execute:

```python highlight={26,27}
# Decision agent
classifier = Agent(
    name="classifier",
    model="openai/gpt-4o-mini",
    system_prompt="Respond with 'urgent' or 'normal'."
)

# Processing agents
urgent_handler = Agent(
    name="urgent_handler",
    model="openai/gpt-4o",
    system_prompt="Handle urgent requests quickly."
)

normal_handler = Agent(
    name="normal_handler",
    model="openai/gpt-4o-mini", 
    system_prompt="Handle normal requests efficiently."
)

# Smart workflow
workflow = (
    Workflow(name="smart_processor")
    .step(classifier)
    .step(urgent_handler, when=lambda: "urgent" in classifier.output.lower())
    .step(normal_handler, when=lambda: "normal" in classifier.output.lower())
)
```
