Sawalni API (1.0.0)

Download OpenAPI specification:Download

Search

Search across multiple languages with summarization

Request Body schema: application/json
required
query
required
string

The search query

extra_languages
required
Array of strings
Items Enum: "en" "ar" "es" "fr"

Additional languages to search in besides the query language

model
string
Default: "sawalni-small"
Enum: "sawalni-large" "sawalni-small" "sawalni-mini" "sawalni-micro"

ID of the model to use for translations and summary

rerank
boolean
Default: true

Whether to rerank results using embeddings

stream
boolean
Default: false

Whether to stream back partial progress. In this case the response will first contain results and then the summary will be streamed as a succession chunks with a string property s.

Responses

Request samples

Content type
application/json
{
  • "query": "string",
  • "extra_languages": [
    ],
  • "model": "sawalni-large",
  • "rerank": true,
  • "stream": false
}

Response samples

Content type
{
  • "results": [
    ],
  • "summary": "string"
}

Chat

Create a chat completion

Request Body schema: application/json
required
required
Array of objects

Array of messages comprising the conversation so far

model
required
string
Enum: "sawalni-large" "sawalni-small" "sawalni-mini" "sawalni-micro"

ID of the model to use

stream
boolean
Default: false

Whether to stream back partial progress

temperature
number [ 0 .. 1 ]
Default: 0.7

Controls randomness in the response

top_p
number [ 0 .. 1 ]
Default: 0.95

Nucleus sampling threshold

top_k
integer >= 1
Default: 40

Limits vocabulary to top K tokens

max_tokens
integer >= 1
Default: 512

Maximum number of tokens to generate

presence_penalty
number [ -2 .. 2 ]
Default: 0

Penalty for new tokens based on presence

frequency_penalty
number [ -2 .. 2 ]
Default: 0

Penalty for new tokens based on frequency

string or Array of strings

Sequences where the API will stop generating

suffix
string

Suffix that comes after completion

repeat_penalty
number

Penalty for repeated tokens

Responses

Request samples

Content type
application/json
{
  • "messages": [
    ],
  • "model": "sawalni-large",
  • "stream": false,
  • "temperature": 0.7,
  • "top_p": 0.95,
  • "top_k": 40,
  • "max_tokens": 512,
  • "presence_penalty": 0,
  • "frequency_penalty": 0,
  • "stop": "string",
  • "suffix": "string",
  • "repeat_penalty": 0
}

Response samples

Content type
{
  • "data": {
    }
}

Embeddings

Generate multilingual embeddings for text. OpenAI compatible.

Authorizations:
BearerAuth
Request Body schema: application/json
required
One of
input
required
string

Single text to generate embedding for

model
string
Default: "madmon-mini"
Enum: "madmon-mini" "madmon-medium" "all-MiniLM-L12-v2" "paraphrase-multilingual-MiniLM-L12-v2" "all-mpnet-base-v2" "paraphrase-multilingual-mpnet-base-v2"

Model to use for embedding generation. "all" models are English-only, "paraphrase-multilingual" models support 50+ languages, "madmon" models support multiple languages including English and Moroccan Darija in Latin and Arabic scripts.

Responses

Request samples

Content type
application/json
{
  • "input": [
    ],
  • "model": "madmon-medium"
}

Response samples

Content type
application/json
{
  • "object": "list",
  • "data": [
    ],
  • "model": "string"
}

Content Moderation

Predict if text contains inappropriate content

Request Body schema: application/json
required
text
required
string

Text to analyze for inappropriate content

Responses

Request samples

Content type
application/json
{
  • "text": "string"
}

Response samples

Content type
application/json
{
  • "data": {
    }
}

Classify text into content categories

Request Body schema: application/json
required
text
required
string

Text to classify

Responses

Request samples

Content type
application/json
{
  • "text": "string"
}

Response samples

Content type
application/json
{
  • "data": {
    }
}

Language Identification

Identify language of text

Request Body schema: application/json
required
One of
input
required
string

Single text to identify language for

model
string
Default: "gherbal-mini"

Model to use for language identification

top
integer
Default: 1

Number of top language predictions to return (-1 for all)

Responses

Request samples

Content type
application/json
{
  • "input": [
    ],
  • "model": "gherbal-mini",
  • "top": 1
}

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "model": "string"
}

Text Translation

Translate text

Request Body schema: application/json
required
text
required
string

Text to be translated

source
required
string

Source language code

target
required
string

Target language code

model
string
Default: "tarjamli-medium"

Model to use for translation

Responses

Request samples

Content type
application/json
{
  • "text": "string",
  • "source": "string",
  • "target": "string",
  • "model": "tarjamli-medium"
}

Response samples

Content type
application/json
{
  • "data": {
    }
}

Text Transliteration

Transliterate text in Moroccan between Arabic and Latin scripts

Request Body schema: application/json
required
required
string or Array of strings

Text or array of texts to transliterate

model
string
Default: "daktilo-mini"
Value: "daktilo-mini"

Model to use for transliteration

to
string
Default: "latn"
Enum: "latn" "arab"

Target script (latn for Latin, arab for Arabic). Only "latn" is supported for now.

temperature
number
Default: 0.1

Temperature for the model

Responses

Request samples

Content type
application/json
{
  • "text": "string",
  • "model": "daktilo-mini",
  • "to": "latn",
  • "temperature": 0.1
}

Response samples

Content type
application/json
{
  • "data": {
    }
}