Next Steps
Youβve completed the getting started guide! Hereβs where to go next.
Table of contents
- π Congratulations!
- Learning Paths
- Quick Reference: Key Features
- Example Gallery
- Common Recipes
- Troubleshooting
- Community & Support
- Recommended Learning Order
- Quick Links
- What to Build?
- Ready to Build?
π Congratulations!
Youβve successfully:
β Installed LLM4S β Written your first LLM program β Configured providers and API keys β Understood Result-based error handling
Now letβs explore what you can build with LLM4S!
Learning Paths
Choose your path based on what you want to build:
π€ Path 1: Build Agents
Best for: Interactive applications, chatbots, assistants
What youβll learn:
- Agent framework basics
- Multi-turn conversations
- Tool calling and integration
- Conversation state management
Start here:
Example project ideas:
- Customer support chatbot
- Code review assistant
- Research assistant with web search
- Interactive game master
π οΈ Path 2: Tool Integration
Best for: LLMs that interact with external systems
What youβll learn:
- Defining custom tools
- Tool parameter schemas
- Model Context Protocol (MCP)
- Tool error handling
Start here:
Example project ideas:
- Database query assistant
- API integration agent
- File system navigator
- Task automation system
π¬ Path 3: Conversational AI
Best for: Chat applications, dialogue systems
What youβll learn:
- Context window management
- Conversation persistence
- History pruning strategies
- Streaming responses
Start here:
Example project ideas:
- Slack bot
- Discord integration
- Customer service chat
- Educational tutor
π Path 4: RAG & Knowledge
Best for: Question answering, document search, knowledge bases
What youβll learn:
- Vector embeddings
- Semantic search
- Document processing
- Retrieval-augmented generation
Start here:
Example project ideas:
- Documentation Q&A system
- PDF analyzer
- Knowledge base search
- Code search engine
π Path 5: Production Systems
Best for: Deploying LLM apps to production
What youβll learn:
- Error handling patterns
- Observability and tracing
- Performance optimization
- Security best practices
Start here:
Example project ideas:
- Scalable API service
- Multi-tenant SaaS application
- Enterprise integration
- Monitoring dashboard
Quick Reference: Key Features
Agents
Build sophisticated multi-turn agents with automatic tool calling.
1
2
val agent = new Agent(client)
val state = agent.run("Your query", tools)
Tool Calling
Give LLMs access to external functions and APIs.
1
2
3
4
5
val tool = ToolFunction(
name = "search",
description = "Search the web",
function = search _
)
Multi-Turn Conversations
Functional conversation management without mutation.
1
val state2 = agent.continueConversation(state1, "Next question")
Context Management
Automatically manage token windows and prune history.
1
2
3
4
val config = ContextWindowConfig(
maxMessages = Some(20),
pruningStrategy = PruningStrategy.OldestFirst
)
Streaming
Get real-time token-by-token responses.
1
2
val stream = client.completeStreaming(messages, None)
stream.foreach(chunk => print(chunk.content))
Observability
Trace LLM calls with Langfuse integration.
1
2
// Automatic tracing when configured
TRACING_MODE=langfuse
Embeddings
Create and search vector embeddings.
1
2
val embeddings = embeddingsClient.embed(documents)
val results = search(query, embeddings)
MCP Integration
Connect to external Model Context Protocol servers.
1
val mcpTools = MCPClient.loadTools("mcp-server-name")
Example Gallery
Browse 69 working examples organized by category:
Basic Examples (9)
- Basic LLM Calling
- Streaming Responses
- Multi-Provider Setup
- Ollama (Local Models)
- Tracing Integration
Agent Examples (6)
- Single-Step Agent
- Multi-Step Agent
- Multi-Turn Conversations
- Long Conversations
- Conversation Persistence
- MCP Agent
Tool Examples (5)
Context Management Examples (8)
More Examples
- Embeddings (5 examples)
- MCP Integration (3 examples)
- Streaming (2 examples)
Common Recipes
Recipe 1: Simple Q&A Bot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import org.llm4s.llmconnect.LLMConnect
import org.llm4s.llmconnect.model._
def askQuestion(question: String): String = {
val result = for {
client <- LLMConnect.create()
response <- client.complete(
List(
SystemMessage("You are a helpful Q&A assistant."),
UserMessage(question)
),
None
)
} yield response.content
result.getOrElse("Sorry, I couldn't process that question.")
}
Recipe 2: Agent with Custom Tools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import org.llm4s.agent.Agent
import org.llm4s.toolapi.{ ToolFunction, ToolRegistry }
def getCurrentTime(): String =
java.time.LocalDateTime.now().toString
val timeTool = ToolFunction(
name = "get_time",
description = "Get current date and time",
function = getCurrentTime _
)
val result = for {
client <- LLMConnect.create()
tools = new ToolRegistry(Seq(timeTool))
agent = new Agent(client)
state <- agent.run("What time is it?", tools)
} yield state.finalResponse
Recipe 3: Streaming Chat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def streamChat(message: String): Unit = {
val result = for {
client <- LLMConnect.create()
stream <- client.completeStreaming(
List(UserMessage(message)),
None
)
} yield {
stream.foreach(chunk => print(chunk.content))
println()
}
result.left.foreach(error => println(s"Error: $error"))
}
Recipe 4: Multi-Turn with Pruning
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import org.llm4s.agent.{ Agent, ContextWindowConfig, PruningStrategy }
val config = ContextWindowConfig(
maxMessages = Some(20),
preserveSystemMessage = true,
pruningStrategy = PruningStrategy.OldestFirst
)
// Turn 1
val state1 = agent.run("First question", tools)
// Turn 2 with pruning
val state2 = agent.continueConversation(
state1.getOrElse(???),
"Follow-up question",
contextWindowConfig = Some(config)
)
Troubleshooting
Common Issues
Problem: API key errors
- Check environment variables are set:
echo $OPENAI_API_KEY - Verify
.envfile is sourced:source .env - Check key starts with correct prefix (
sk-for OpenAI,sk-ant-for Anthropic)
Problem: Model not found
- Verify
LLM_MODELformat:provider/model-name - Check provider supports that model
- Try a different model
Problem: Slow responses
- Use streaming for real-time feedback
- Consider using a faster model (gpt-3.5-turbo, claude-haiku)
- Check your internet connection
Problem: Token limit errors
- Implement context window pruning
- Use shorter system prompts
- Summarize conversation history
Full troubleshooting guide β
Community & Support
Get Help
- Discord: Join our community - Active community for questions
- GitHub Issues: Report bugs - Bug reports and feature requests
- Documentation: Browse the user guide - Comprehensive guides
- Examples: Check working examples - 46 code samples
Stay Updated
- GitHub: Star the repo - Get notified of updates
- Roadmap: View the roadmap - See whatβs coming
- Changelog: Release notes - Track changes
Contribute
- Starter Kit: Use llm4s.g8 to scaffold projects
- Share Examples: Post your projects in Discord
- Contribute: See the contributing guide
Recommended Learning Order
Week 1: Fundamentals
- β Complete Getting Started (you are here!)
- Read Basic Usage Guide
- Try Basic Examples
- Experiment with different providers
Week 2: Agents & Tools
- Read Agent Framework
- Build a simple agent with one tool
- Try Tool Examples
- Add multiple tools
Week 3: Advanced Patterns
- Implement Multi-Turn Conversations
- Add Context Management
- Set up Observability
- Try Long Conversation Example
Week 4: Production
- Read Production Guide
- Implement error handling
- Add monitoring and tracing
- Deploy your first production agent
Quick Links
Documentation
- User Guide - Feature guides
- API Reference - API docs
- Advanced Topics - Production topics
Examples
- All Examples - Browse 46 examples
- Basic - Getting started
- Agents - Agent patterns
- Tools - Tool integration
Reference
- Configuration - Setup guide
- Migration Guide - Version upgrades
- Roadmap - Future plans
What to Build?
Need inspiration? Here are some project ideas:
Beginner Projects:
- Simple Q&A bot
- Code explainer
- Translation service
- Writing assistant
Intermediate Projects:
- Multi-tool research agent
- Database query interface
- API integration bot
- Document summarizer
Advanced Projects:
- Multi-agent system
- RAG-powered knowledge base
- Production chatbot service
- Custom tool ecosystem
Ready to Build?
Pick your learning path and start building:
π€ Build Agents
Agent Framework βπ οΈ Add Tools
Tool Calling βπ¬ Chat Apps
Multi-Turn βπ RAG Systems
Embeddings βHappy building with LLM4S! π
Questions? Join our Discord