Run AI Models Locally with Docker Model Runner and Spring AI Docker Model Runner enables Java developers to run AI models locally and integrate them with Spring AI applications, eliminating the need for cloud-hosted model APIs during development. The tool exposes an OpenAI-compatible API, allowing Spring AI's abstractions like ChatModel and ChatClient to communicate with local models, reducing API costs and keeping data on-premises. Generative AI development doesn't always require a cloud-hosted model. If you're building Java applications with Spring AI, you can run AI models locally and connect them to your Spring Boot application without depending on external model APIs. One interesting option is Docker Model Runner . In this article, we'll explore how Docker Model Runner works, why it is useful for Java developers, and how to connect it with Spring AI. Docker Model Runner allows you to run AI models locally using Docker. Instead of sending every prompt to a cloud provider such as OpenAI or AWS Bedrock, you can run supported models on your own machine. The architecture looks like this: Spring Boot Application | v Spring AI | v OpenAI-compatible API | v Docker Model Runner | v Local LLM Your Java application interacts with the model through an API, while Docker handles running the model locally. This gives developers a convenient way to experiment with LLM applications without immediately provisioning cloud infrastructure. There are several reasons you may want to run an LLM locally. During development, you may send hundreds or thousands of prompts. Running a model locally can eliminate API charges during experimentation. Your prompts and application data can remain on your machine instead of being sent to an external AI provider. This can be particularly useful when experimenting with sensitive or proprietary data. Once the model is available locally, you don't need an internet connection for every inference request. Developers can experiment with prompts, tool calling, RAG pipelines, and application logic without repeatedly configuring cloud credentials. One of the biggest advantages is that your application can continue using Spring AI abstractions. Your business logic doesn't need to be tightly coupled to a specific model provider. Spring AI provides abstractions such as: ChatModel ChatClient This means your application can interact with an LLM without having to directly implement provider-specific HTTP calls. The important idea is: Application | v ChatClient | v ChatModel | v Model API | v Local Model If your local model exposes an OpenAI-compatible API, Spring AI can communicate with it using the appropriate OpenAI configuration. First, make sure Docker Desktop is installed and running on your machine. Docker Model Runner is available through Docker's model functionality, depending on your Docker Desktop version and configuration. You can verify that Docker is available with: docker --version Then make sure Docker Desktop is running. Docker Desktop provides the model-running infrastructure required to run supported AI models locally. Once enabled, you can work with models directly through Docker. The exact commands and model availability can change as Docker's model ecosystem evolves, so check the current Docker documentation for the model you want to use. The important concept for our Spring AI application is that Docker Model Runner exposes an API endpoint that our application can communicate with. Create a Spring Boot application with Spring AI. For Maven, add the Spring AI OpenAI starter: