Create an inference endpoint Generally available; Added in 8.11.0

PUT /_inference/{task_type}/{inference_id}

All methods and paths for this operation:

PUT /_inference/{inference_id}

PUT /_inference/{task_type}/{inference_id}

IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Mistral, Azure OpenAI, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face. For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs.

The following integrations are available through the inference API. You can find the available task types next to the integration name:

  • AI21 (chat_completion, completion)
  • AlibabaCloud AI Search (completion, rerank, sparse_embedding, text_embedding)
  • Amazon Bedrock (chat_completion, completion, text_embedding)
  • Amazon SageMaker (chat_completion, completion, rerank, sparse_embedding, text_embedding)
  • Anthropic (chat_completion, completion)
  • Azure AI Studio (completion, rerank, text_embedding)
  • Azure OpenAI (chat_completion, completion, text_embedding)
  • Cohere (completion, rerank, text_embedding)
  • DeepSeek (chat_completion, completion)
  • Elasticsearch (rerank, sparse_embedding, text_embedding - this service is for built-in models and models uploaded through Eland)
  • ELSER (sparse_embedding)
  • Fireworks AI (chat_completion, completion, text_embedding)
  • Google AI Studio (completion, text_embedding)
  • Google Vertex AI (chat_completion, completion, rerank, text_embedding)
  • Groq (chat_completion)
  • Hugging Face (chat_completion, completion, rerank, text_embedding)
  • JinaAI (embedding, rerank, text_embedding)
  • Llama (chat_completion, completion, text_embedding)
  • Mistral (chat_completion, completion, text_embedding)
  • Nvidia (chat_completion, completion, text_embedding, rerank)
  • OpenAI (chat_completion, completion, text_embedding)
  • OpenShift AI (chat_completion, completion, rerank, text_embedding)
  • VoyageAI (rerank, text_embedding)
  • Watsonx (chat_completion, completion, rerank, text_embedding)

Required authorization

  • Cluster privileges: manage_inference

Path parameters

  • task_type string Required

    The task type. Refer to the integration list in the API description for the available task types.

    Values are sparse_embedding, text_embedding, rerank, completion, chat_completion, embedding, document_extraction, or decision.

  • inference_id string Required

    The inference Id

Query parameters

  • timeout string

    Specifies the amount of time to wait for the inference endpoint to be created. The default depends on the task type: 120s for completion and chat_completion, and 30s for all other task types.

    External documentation
application/json

Body Required

  • chunking_settings object

    The chunking configuration object. Applies only to the embedding, sparse_embedding and text_embedding task types. Not applicable to the rerank, completion, or chat_completion task types.

    Hide chunking_settings attributes Show chunking_settings attributes object
    • max_chunk_size number

      The maximum size of a chunk in words. This value cannot be lower than 20 (for sentence strategy) or 10 (for word strategy). This value should not exceed the window size for the associated model.

      Default value is 250.

    • overlap number

      The number of overlapping words for chunks. It is applicable only to a word chunking strategy. This value cannot be higher than half the max_chunk_size value.

      Default value is 100.

    • sentence_overlap number

      The number of overlapping sentences for chunks. It is applicable only for a sentence chunking strategy. It can be either 1 or 0.

      Default value is 1.

    • separator_group string

      Only applicable to the recursive strategy and required when using it.

      Sets a predefined list of separators in the saved chunking settings based on the selected text type. Values can be markdown or plaintext.

      Using this parameter is an alternative to manually specifying a custom separators list.

    • separators array[string]

      Only applicable to the recursive strategy and required when using it.

      A list of strings used as possible split points when chunking text.

      Each string can be a plain string or a regular expression (regex) pattern. The system tries each separator in order to split the text, starting from the first item in the list.

      After splitting, it attempts to recombine smaller pieces into larger chunks that stay within the max_chunk_size limit, to reduce the total number of chunks generated.

    • strategy string

      The chunking strategy: sentence, word, none or recursive.

      • If strategy is set to recursive, you must also specify:

        • max_chunk_size
        • either separators orseparator_group

      Learn more about different chunking strategies in the linked documentation.

      Default value is sentence.

      External documentation
  • service string Required

    The service type

  • service_settings object Required

    Settings specific to the service

  • task_settings object

    Task settings specific to the service and task type

Responses

  • 200 application/json
    Hide response attributes Show response attributes object

    Represents an inference endpoint as returned by the GET API

    • chunking_settings object

      The chunking configuration object. Applies only to the embedding, sparse_embedding and text_embedding task types. Not applicable to the rerank, completion, or chat_completion task types.

      Hide chunking_settings attributes Show chunking_settings attributes object
      • max_chunk_size number

        The maximum size of a chunk in words. This value cannot be lower than 20 (for sentence strategy) or 10 (for word strategy). This value should not exceed the window size for the associated model.

        Default value is 250.

      • overlap number

        The number of overlapping words for chunks. It is applicable only to a word chunking strategy. This value cannot be higher than half the max_chunk_size value.

        Default value is 100.

      • sentence_overlap number

        The number of overlapping sentences for chunks. It is applicable only for a sentence chunking strategy. It can be either 1 or 0.

        Default value is 1.

      • separator_group string

        Only applicable to the recursive strategy and required when using it.

        Sets a predefined list of separators in the saved chunking settings based on the selected text type. Values can be markdown or plaintext.

        Using this parameter is an alternative to manually specifying a custom separators list.

      • separators array[string]

        Only applicable to the recursive strategy and required when using it.

        A list of strings used as possible split points when chunking text.

        Each string can be a plain string or a regular expression (regex) pattern. The system tries each separator in order to split the text, starting from the first item in the list.

        After splitting, it attempts to recombine smaller pieces into larger chunks that stay within the max_chunk_size limit, to reduce the total number of chunks generated.

      • strategy string

        The chunking strategy: sentence, word, none or recursive.

        • If strategy is set to recursive, you must also specify:

          • max_chunk_size
          • either separators orseparator_group

        Learn more about different chunking strategies in the linked documentation.

        Default value is sentence.

        External documentation
    • service string Required

      The service type

    • service_settings object Required

      Settings specific to the service

    • task_settings object

      Task settings specific to the service and task type

    • inference_id string Required

      The inference Id

    • task_type string Required

      The task type

      Values are sparse_embedding, text_embedding, rerank, completion, chat_completion, embedding, document_extraction, or decision.

    • metadata object Generally available; Added in 9.4.0

      Metadata about the endpoint, such as the model it serves, where it is available and what it supports. It is returned for the endpoints of the Elastic Inference Service.

      Hide metadata attributes Show metadata attributes object
      • heuristics object Required

        Properties of the endpoint that help clients to determine which model to use.

        Hide heuristics attributes Show heuristics attributes object
        • properties array[string] Required

          Tags that describe the properties of the model, for example multilingual, english or multimodal.

        • release_date string

          The date on which the model was released, in yyyy-MM-dd format.

        • end_of_life_date string

          The date on which the model reaches the end of its life, in yyyy-MM-dd format.

      • display object Required

        Information to display for the endpoint.

        Hide display attributes Show display attributes object
        • name string

          The name to display for the endpoint.

        • model_creator string

          The creator of the model, for display purposes.

      • model_identity object Generally available; Added in 9.6.0

        The identity of the model that the endpoint serves.

        Hide model_identity attributes Show model_identity attributes object
        • creator string

          The model creator or lab, for example anthropic, openai or jina.

        • family string

          The model family within the creator, for example claude, gpt or gemini.

        • tier string

          The performance or size tier within the family, for example sonnet or mini. It is not set if the model has no tier variants.

        • version string

          The version of the model.

      • regions array[object] Generally available; Added in 9.5.0

        The regions in which the endpoint is available.

        Hide regions attributes Show regions attributes object
        • csp string

          The cloud service provider, for example aws, gcp or azure.

        • region string

          The region of the cloud service provider, for example us-east-1.

        • geo string

          The geographic area, for example us or eu.

        • region_display_name string

          The human-readable name of the region.

      • denied_by_region_policy boolean Generally available; Added in 9.5.0

        If true, the region policy of the caller prohibits access to the endpoint.

      • capabilities object Generally available; Added in 9.6.0

        The capabilities of the endpoint.

PUT /_inference/{task_type}/{inference_id}
PUT _inference/rerank/my-rerank-model
{
 "service": "cohere",
 "service_settings": {
   "model_id": "rerank-english-v3.0",
   "api_key": "{{COHERE_API_KEY}}"
 }
}
resp = client.inference.put(
    task_type="rerank",
    inference_id="my-rerank-model",
    inference_config={
        "service": "cohere",
        "service_settings": {
            "model_id": "rerank-english-v3.0",
            "api_key": "{{COHERE_API_KEY}}"
        }
    },
)
const response = await client.inference.put({
  task_type: "rerank",
  inference_id: "my-rerank-model",
  inference_config: {
    service: "cohere",
    service_settings: {
      model_id: "rerank-english-v3.0",
      api_key: "{{COHERE_API_KEY}}",
    },
  },
});
response = client.inference.put(
  task_type: "rerank",
  inference_id: "my-rerank-model",
  body: {
    "service": "cohere",
    "service_settings": {
      "model_id": "rerank-english-v3.0",
      "api_key": "{{COHERE_API_KEY}}"
    }
  }
)
$resp = $client->inference()->put([
    "task_type" => "rerank",
    "inference_id" => "my-rerank-model",
    "body" => [
        "service" => "cohere",
        "service_settings" => [
            "model_id" => "rerank-english-v3.0",
            "api_key" => "{{COHERE_API_KEY}}",
        ],
    ],
]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"service":"cohere","service_settings":{"model_id":"rerank-english-v3.0","api_key":"{{COHERE_API_KEY}}"}}' "$ELASTICSEARCH_URL/_inference/rerank/my-rerank-model"
var response = await client.Inference
    .PutAsync(new PutInferenceRequest()
    {
        InferenceId = "my-rerank-model",
        TaskType = TaskType.Rerank,
        InferenceConfig = new()
        {
            Service = "cohere",
            ServiceSettings = JsonSerializer.Deserialize<JsonElement>("""
            {
              "model_id": "rerank-english-v3.0",
              "api_key": "{{COHERE_API_KEY}}"
            }
            """)
        }
    });
client.inference().put(p -> p
    .inferenceId("my-rerank-model")
    .taskType(TaskType.Rerank)
    .inferenceConfig(i -> i
        .service("cohere")
        .serviceSettings(JsonData.fromJson("""
{"model_id":"rerank-english-v3.0","api_key":"{{COHERE_API_KEY}}"}
"""))
    )
);
Request example
An example body for a `PUT _inference/rerank/my-rerank-model` request.
{
 "service": "cohere",
 "service_settings": {
   "model_id": "rerank-english-v3.0",
   "api_key": "{{COHERE_API_KEY}}"
 }
}