Perform inference on the service Added in 8.11.0

POST /_inference/{task_type}/{inference_id}

Path parameters

  • task_type string Required

    The task type

    Values are sparse_embedding, text_embedding, rerank, or completion.

  • inference_id string Required

    The inference Id

Query parameters

  • timeout string

    Specifies the amount of time to wait for the inference request to complete.

application/json

Body

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • Hide text_embedding_bytes attribute Show text_embedding_bytes attribute object
      • embedding array[number] Required

        Text Embedding results containing bytes are represented as Dense Vectors of bytes.

    • text_embedding array[object]
      Hide text_embedding attribute Show text_embedding attribute object
      • embedding array[number] Required

        Text Embedding results are represented as Dense Vectors of floats.

    • sparse_embedding array[object]
      Hide sparse_embedding attribute Show sparse_embedding attribute object
      • embedding object Required

        Sparse Embedding tokens are represented as a dictionary of string to double.

        Hide embedding attribute Show embedding attribute object
        • * number Additional properties
    • completion array[object]
      Hide completion attribute Show completion attribute object
    • rerank array[object]
      Hide rerank attributes Show rerank attributes object
POST /_inference/{task_type}/{inference_id}
curl \
 -X POST http://api.example.com/_inference/{task_type}/{inference_id} \
 -H "Content-Type: application/json" \
 -d '{"query":"string","input":"string","task_settings":{}}'
Request examples
{
  "query": "string",
  "input": "string",
  "task_settings": {}
}
Response examples (200)
{
  "text_embedding_bytes": [
    {
      "embedding": [
        42.0
      ]
    }
  ],
  "text_embedding": [
    {
      "embedding": [
        42.0
      ]
    }
  ],
  "sparse_embedding": [
    {
      "embedding": {
        "additionalProperty1": 42.0,
        "additionalProperty2": 42.0
      }
    }
  ],
  "completion": [
    {
      "result": "string"
    }
  ],
  "rerank": [
    {
      "index": 42.0,
      "score": 42.0,
      "text": "string"
    }
  ]
}