{"error":"invalid input type"} with HTTP 400 is Ollama's /api/embed refusing an input of the wrong JSON type: a number or an array of numbers in the test. Send a string, or an array of strings; both returned embeddings.

A number ("input":42) and an array of numbers ("input":[1,2]) gave this message. An empty object gave a different one, input item has no text, image, or audio, also with 400.

The error

{"model":"all-minilm","input":42}
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/api/embed -d "@emb0.json"
{"error":"invalid input type"}
HTTP 400
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/api/embed -d "@emb2.json"
{"error":"invalid input type"}
HTTP 400

emb2.json was {"model":"all-minilm","input":[1,2]}.

Why it happens

input carries the text to embed. A bare number is not text, and neither is a list of numbers, so the server answered with the generic type message without saying which type it wanted. The fix below shows the two shapes that worked. If a number is what you want embedded, convert it to a string first and send that.

An object is read differently: "input":{} came back with {"error":"input item has no text, image, or audio"}. So the two messages point at two different mistakes: a number or an array of numbers, or an object (the test used the empty object {}). If you meant plain text, send it as a string either way.

The fix

{"model":"all-minilm","input":"Maria Garcia booked a room"}
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/api/embed -d "@emb-ok.json"
{"model":"all-minilm","embeddings":[[0.040565662,-0.027005056,-0.048808623,0.049912073,-0.017312804,0.04209565,0.0279564...
HTTP 200
{"model":"all-minilm","input":["first text","second text"]}
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/api/embed -d "@emb-list.json"
{"model":"all-minilm","embeddings":[[-0.017102975,0.054488022,0.009093067,0.045167476,-0.0308149,0.04608282,0.096649334,...
HTTP 200

A single string gave one vector in embeddings; an array of two strings gave two. Batching several texts in one array is the way to embed a list without one request per item. The model name stays the same in every case: the error is about the value of input, and all-minilm answered normally as soon as that value was text.

How it was reproduced

On Windows 11 in Windows PowerShell 5.1 with curl 8.22.0 and Ollama 0.40.16, against a separate test server on 127.0.0.1:15190 with its own models folder and the all-minilm embedding model. Each body was written with [IO.File]::WriteAllText and posted to /api/embed: a number, an empty object, an array of numbers, a string and an array of strings. The vector count was read with ConvertFrom-Json.

Frequently asked

Why does Ollama /api/embed say invalid input type?
The input field held something other than a string or an array of strings, for example the number 42 or an array of numbers. Send the text as a string.
How do I embed several texts in one Ollama request?
Send input as an array of strings. In the test two strings returned two vectors in the embeddings array.
What does 'input item has no text, image, or audio' mean?
In the test it was the answer to an empty object as the input of /api/embed. Send plain text as a string instead of an object.

More decoded errors in the Fixes category. If the input is text but the model is a chat model, see the 501 post for /api/embed.