Create Meilisearch embedders using any provider with a REST API
"rest"
:
source
, and a url
is mandatory for all REST embedders.
request
field defines the structure of the input it will send to the provider. The way you must fill this field changes for each provider.
For example, Mistral expects two mandatory parameters: model
and input
. It also accepts one optional parameter: encoding_format
. Cloudflare instead only expects a single field, text
.
model
must be a string specifying a valid Mistral model.
Update your embedder object adding this field and its value:
request
.
input
field. In Cloudflare, it’s called text
.
Most providers accept either a string or an array of strings. A single string will generate one request per document in your database:
{{text}}
indicates Meilisearch should replace the contents of a field with your document data, as indicated in the embedder’s documentTemplate
.
An array of strings allows Meilisearch to send up to 10 documents in one request, reducing the number of API calls to the provider:
{{text}}
. If you want to send multiple documents in a single request, the second array item must be {{..}}
. When using "{{..}}"
, it must be present in both request
and response
.
When using other embedding providers, input
might be called something else, like text
or prompt
:
request
object as you need. Meilisearch will include them when querying the embeddings provider.
For example, Mistral allows you to optionally configure an encoding_format
. Set it by declaring this field in your embedder’s request
:
response.result.data
. Describe the full path to the embedding array in your embedder’s response
. The first array item must be "{{embedding}}"
:
"{{..}}"
as its second value:
"{{..}}"
, it must be present in both request
and response
.
It is possible the response contains a single embedding outside of an array. Use "{{embedding}}"
as its value:
response
fields not pointing to an "{{embedding}}"
value.
api-key
header containing an API key.
Add the headers
field to your embedder object:
Content-Type
header. It may also include an authorization bearer token, if you have supplied an API key.
source
, request
, response
, and header
are the only fields specific to REST embedders.
Like other remote embedders, you’re likely required to supply an apiKey
:
documentTemplate
. Good templates are short and include only highly relevant document data:
request
response
header