Inference API not working

Hi,

I was trying to embed some text with a model I uploaded in my local docker instance of elastic.

I currently have elastic 8.11 here.

When trying to do this I receive the following error:
API Call (Kibana DevTools)

GET /_inference/_all

Error Message:

{
  "error": "Incorrect HTTP method for uri [/_inference/_all?pretty=true] and method [GET], allowed: [POST]",
  "status": 405
}

Now I see it asks for a POST instead of a GET.
However according to this page it needs a GET.
When trying with a POST:
API Call:

POST /_inference/_all

Returns:

{
  "error": "no handler found for uri [/_inference/_all?pretty=true] and method [POST]"
}

Same happens when trying to embed the text.

However this should work according to this page.

Help is appreciated.

Kind regards,
Chenko

I figured I was doing something wrong. What I wanted to do is the following:

POST /_ml/trained_models/elastic__multilingual-e5-small-optimized/_infer
{
  "docs": {
    "text_field": "test text query"
  }
}

This does give good results.

However this does not mean the error above is now irrelevant.

I still want to figure out why this happens.

Are you sure that you only have:

GET /_inference/_all

and not something like:

GET /_inference/_all
{
}

If the later, Kibana transforms the GET request to a POST as GET with body is not always supported. That's why you are seeing this error.

Make sure that you have an empty line after:

GET /_inference/_all

Hey David,

I do only have a GET request. which is why he asks for a POST I think?

I should mention however. I am using Elasticsearch 8.11.

I tried it just now with Elasticsearch 8.13 and it does work with that version.

Hi Chenko

It looks like you installed the built in E5 model in machine learning. To use that model you should use the _ml/trained_models APIs as you have correctly noted.

The inference API is new integration point that enables access to LLMs hosted by OpenAI and others. I recommend upgrading to the latest version of Elastic to get all the features

GET /_inference/_all

Unfortunately the docs are wrong on this one. The GET /_inference/_all form was added in 8.13 and is not available in 8.11.

These 2 calls should work in 8.11

GET /_inference/<task_type>/_all
GET /_inference/<task_type>/<model_id>

1 Like