Skip to content

Ollama: Support custom Ollama API paths #3470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lambochen
Copy link
Contributor

Thank you for taking time to contribute this pull request!
You might have already read the [contributor guide][1], but as a reminder, please make sure to:

  • Sign the contributor license agreement
  • Rebase your changes on the latest main branch and squash your commits
  • Add/Update unit tests as needed
  • Run a build and make sure all tests pass prior to submission

Hi, This PR is a feature enhancement change that supports custom Ollama API paths.

Background: When implementing Spring AI in my project, I made some adjustments to the Ollama API, and the API provided externally is a custom path. Therefore, I expect the Spring AI Ollama Model to support custom paths.

Current behavior: The Ollama API path is fixed in the hard-coded code, for example:

public ListModelResponse listModels() {
	return this.restClient.get()
			.uri("/api/tags")
			.retrieve()
			.body(ListModelResponse.class);
}

@lambochen
Copy link
Contributor Author

ref: #3471

@lambochen
Copy link
Contributor Author

@ThomasVitale @dev-jonghoonpark
Hi, please review the PR, thank you.

@lambochen lambochen requested a review from yuluo-yx June 8, 2025 16:18
@dev-jonghoonpark
Copy link
Contributor

dev-jonghoonpark commented Jun 9, 2025

Just out of personal curiosity, Can you be more specific with your example?
I've seen the OpenAI API compatible API many times, but this is the first time I've seen the
Ollama API compatible format.

@lambochen
Copy link
Contributor Author

lambochen commented Jun 9, 2025

but this is the first time I've seen the Ollama API compatible format.

Thank you for your interest in this capability.
I am working on an experimental service where ollama is deployed remotely (non-local environment), providing platform services to developers. Due to the numerous APIs exposed by the platform, there has been an issue of path conflicts, so it is necessary to support customizing the Ollama API path.

I've seen the OpenAI API compatible API many times

Yes, for similar solutions, we also have custom path requirements for OpenAI and other models (such as DeepSeek).

@ilayaperumalg ilayaperumalg added this to the 1.1.x milestone Jun 9, 2025
Comment on lines +31 to +43
String getChatPath();

String getEmbedPath();

String getListModelsPath();

String getShowModelPath();

String getCopyModelPath();

String getDeleteModelPath();

String getPullModelPath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the connection details should be updated. The connection details to connect to ollama is the baseUrl only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants