Summary
When generating embeddings via the Ollama provider with a dimensions provider option, the option is included in the request payload twice, once as a top-level field, and again nested inside the options object. Ollama doesn't recognize dimensions as a valid model option (it expects things like temperature, num_ctx, etc. inside options), so it logs a warning on every request:
level=WARN source=types.go:977 msg="invalid option provided" option=dimensions
The embeddings still come back successfully, but production logs get spammed.
Version
prism-php/prism v0.99.22
- Ollama (any recent version, the warning was added when Ollama tightened its option validation)
Reproduction
use Prism\Prism\Facades\Prism;
$response = Prism::embeddings()
->using('ollama', 'qwen3-embedding:0.6b')
->fromInput('hello world')
->withProviderOptions(['dimensions' => 1024])
->asEmbeddings();
This call succeeds and returns a 1024-dim embedding, but Ollama's server log shows:
level=WARN source=types.go:977 msg="invalid option provided" option=dimensions
Root cause
In src/Providers/Ollama/Handlers/Embeddings.php (lines 47–56):
$response = $this->client->post(
'api/embed',
Arr::whereNotNull([
'model' => $request->model(),
'input' => $request->inputs(),
'dimensions' => $request->providerOptions('dimensions'),
'keep_alive' => $request->providerOptions('keep_alive'),
'options' => $request->providerOptions() ?: null, // ← includes dimensions + keep_alive again
])
);
$request->providerOptions() (called with no key) returns the entire providerOptions array, so dimensions and keep_alive end up nested inside options in addition to being passed as top-level fields. Ollama then complains about the nested options.dimensions key.
Suggested fix
Exclude the keys that are already passed at the top level from the nested options payload:
$options = Arr::except($request->providerOptions(), ['dimensions', 'keep_alive']);
$response = $this->client->post(
'api/embed',
Arr::whereNotNull([
'model' => $request->model(),
'input' => $request->inputs(),
'dimensions' => $request->providerOptions('dimensions'),
'keep_alive' => $request->providerOptions('keep_alive'),
'options' => $options ?: null,
])
);
Introduced by #913 That PR added the top-level dimensions field but didn't exclude it from the nested options payload.
Summary
When generating embeddings via the Ollama provider with a
dimensionsprovider option, the option is included in the request payload twice, once as a top-level field, and again nested inside theoptionsobject. Ollama doesn't recognizedimensionsas a valid model option (it expects things liketemperature,num_ctx, etc. insideoptions), so it logs a warning on every request:The embeddings still come back successfully, but production logs get spammed.
Version
prism-php/prismv0.99.22Reproduction
This call succeeds and returns a 1024-dim embedding, but Ollama's server log shows:
Root cause
In
src/Providers/Ollama/Handlers/Embeddings.php(lines 47–56):$request->providerOptions()(called with no key) returns the entire providerOptions array, sodimensionsandkeep_aliveend up nested insideoptionsin addition to being passed as top-level fields. Ollama then complains about the nestedoptions.dimensionskey.Suggested fix
Exclude the keys that are already passed at the top level from the nested
optionspayload:Introduced by #913 That PR added the top-level
dimensionsfield but didn't exclude it from the nestedoptionspayload.