A hands-on guide to integrating LLMs into Java applications using the Apache Camel OpenAI component (introduced in Camel 4.17). Covers setting up Maven dependencies, building a basic chat completion route, switching to OpenAI-compatible endpoints like Ollama, maintaining conversational memory by reusing Exchange objects with the conversationMemory option, and returning structured JSON output mapped to a Java POJO using the outputClass option and Jackson deserialization.
Table of contents
1. Overview2. Maven Dependencies3. Basic Interaction With an LLM4. Using Other OpenAI-Compatible Endpoints5. Keeping Conversational Memory6. Providing Structured Output7. Conclusion307 Impressions