# Delete the inference model if it already exists
client.options(ignore_status=[404]).inference.delete(
    inference_id="cohere_embeddings"
)

client.inference.put(
    task_type="text_embedding",
    inference_id="cohere_embeddings",
    body={
        "service": "cohere",
        "service_settings": {
            "api_key": COHERE_API_KEY,
            "model_id": "embed-v4.0",
            "embedding_type": "int8",
            "similarity": "cosine",
        },
        "task_settings": {},
    },
)
```

## Create the Index

The mapping of the destination index – the index that contains the embeddings that the model will generate based on your input text – must be created. The destination index must have a field with the [`semantic_text`](https://www.google.com/url?q=https%3A%2F%2Fwww.elastic.co%2Fguide%2Fen%2Felasticsearch%2Freference%2Fcurrent%2Fsemantic-text.html) field type to index the output of the Cohere model.

Let's create an index named cohere-wiki-embeddings with the mappings we need

```python PYTHON
client.indices.delete(
    index="cohere-wiki-embeddings", ignore_unavailable=True
)
client.indices.create(
    index="cohere-wiki-embeddings",
    mappings={
        "properties": {
            "text_semantic": {
                "type": "semantic_text",
                "inference_id": "cohere_embeddings",
            },
            "text": {"type": "text", "copy_to": "text_semantic"},
            "wiki_id": {"type": "integer"},
            "url": {"type": "text"},
            "views": {"type": "float"},
            "langs": {"type": "integer"},
            "title": {"type": "text"},
            "paragraph_id": {"type": "integer"},
            "id": {"type": "integer"},
        }
    },
)
```

You might see something like this:

```
ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'cohere-wiki-embeddings'})
```

Let's note a few important parameters from that API call:

* `semantic_text`: A field type automatically generates embeddings for text content using an inference endpoint.
* `inference_id`: Specifies the ID of the inference endpoint to be used. In this example, the model ID is set to cohere\_embeddings.
* `copy_to`: Specifies the output field which contains inference results

## Insert Documents

Let's insert our example wiki dataset. You need a production Cohere account to complete this step, otherwise the documentation ingest will time out due to the API request rate limits.

```python PYTHON
url = "https://raw.githubusercontent.com/cohere-ai/cohere-developer-experience/main/notebooks/data/embed_jobs_sample_data.jsonl"
response = requests.get(url)