Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Better ollama configuration (#5644)

vincent d warmerdam2c87dc93e82a
diff --git a/marimo/_server/ai/providers.py b/marimo/_server/ai/providers.py
index 5101209867..a2aa59176b 100644
--- a/marimo/_server/ai/providers.py
+++ b/marimo/_server/ai/providers.py
@@ -207,6 +207,8 @@ class AnyProviderConfig:
elif _model_is_bedrock(model):
return AnyProviderConfig.for_bedrock(config)
else:
+ # OpenAI has a default API that ollama also uses, that is
+ # why it is a catch all at the end here.
return AnyProviderConfig.for_openai(config)
@@ -225,6 +227,10 @@ def _get_key(config: Any, name: str) -> str:
key = config["api_key"]
if key:
return cast(str, key)
+ if "http://127.0.0.1:11434/" in config.get("base_url", ""):
+ # Ollama can be configured and in that case the api key is not needed.
+ # We send a placeholder value to prevent the user from being confused.
+ return "ollama-placeholder"
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,
detail=f"{name} API key not configured",