# Inference API not working

**URL:** <https://discuss.elastic.co/t/inference-api-not-working/358209>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning, docker\
**Created:** [April 25, 2024, 12:21pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209 "2024-04-25T12:21:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chenko](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chenko](https://discuss.elastic.co/u/Chenko)\
**Post date:** [April 25, 2024, 12:21pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209/1 "2024-04-25T12:21:11Z")

</div>

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)

```auto
GET /_inference/_all

```

Error Message:

```auto
{
  "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](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/get-inference-api.html) it needs a GET.  
When trying with a POST:  
API Call:

```auto
POST /_inference/_all

```

Returns:

```auto
{
  "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](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/get-inference-api.html).

Help is appreciated.

Kind regards,  
Chenko

---

<div class="post-metadata">

**Author:** ![Chenko](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chenko](https://discuss.elastic.co/u/Chenko)\
**Post date:** [April 25, 2024, 12:56pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209/2 "2024-04-25T12:56:27Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 25, 2024, 1:33pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209/3 "2024-04-25T13:33:44Z")

</div>

Are you sure that you only have:

```auto
GET /_inference/_all

```

and not something like:

```auto
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:

```auto
GET /_inference/_all

```

---

<div class="post-metadata">

**Author:** ![Chenko](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chenko](https://discuss.elastic.co/u/Chenko)\
**Post date:** [April 25, 2024, 1:39pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209/4 "2024-04-25T13:39:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dkyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkyle/32/59114_2.png) [@dkyle](https://discuss.elastic.co/u/dkyle)\
**Post date:** [April 25, 2024, 2:49pm UTC](https://discuss.elastic.co/t/inference-api-not-working/358209/5 "2024-04-25T14:49:48Z")

</div>

Hi Chenko

It looks like you installed the [built in E5](https://www.elastic.co/guide/en/machine-learning/master/ml-nlp-e5.html) 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](https://github.com/elastic/elasticsearch/pull/104483) 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>`
