Sawalni API
APIsDocumentationOpen portal ↗
Omneity Labs API collection ↗Integration quickstart →API keys and playgrounds →
API Reference

Word Encoding API

Encode words into dense embeddings using Sawtone v4, a remote-code multilingual word encoder that exposes phonetic, orthographic, and semantic word channels through a stable API.

Endpoint

text
POST https://api.sawalni.com/v1/language/encode

Request Body

ParameterTypeRequiredDescription
modelstringYessawtone-v4
inputstring or arrayYesWord(s) or phrase(s) to encode
channelstringNocomposite (544d, default), phonetic (192d), ortho (192d), or semantic (128d)

Channels

ChannelDimensionsDescription
composite544Sawtone v4 composite word embedding
phonetic192CNN-based sound-pattern channel
ortho192Orthographic byte-structure channel
semantic128Base semantic channel inferred from form

Multi-word Input

When input contains multiple words (separated by whitespace), each word is encoded individually and the results are max-pooled into a single vector.

Example — curl

bash
curl https://api.sawalni.com/v1/language/encode \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sawtone-v4", "input": ["hello", "café", "München"], "channel": "composite" }'

Example — Python

python
import requests response = requests.post( "https://api.sawalni.com/v1/language/encode", headers={"Authorization": "Bearer YOUR_API_KEY"}, json={ "model": "sawtone-v4", "input": ["hello", "café", "مرحبا"], "channel": "phonetic" } ) result = response.json() for item in result["data"]: print(f"{item['input']} → {len(item['embedding'])}d embedding")

Example — JavaScript

javascript
const response = await fetch('https://api.sawalni.com/v1/language/encode', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'sawtone-v4', input: ['hello', 'café', 'مرحبا'], channel: 'composite' }) }); const result = await response.json(); result.data.forEach(item => { console.log(item.input, '→', item.embedding.length + 'd'); });

Response

json
{ "data": [ { "input": "hello", "embedding": [0.023, -0.009, 0.015, ...] } ], "model": "sawtone-v4", "channel": "composite", "dimensions": 544, "usage": { "input_bytes": 5, "input_count": 1, "total_words": 1, "processing_ms": 3.2 } }

Batch Encoding

Pass an array of strings to encode multiple texts in one request (max 128):

python
response = requests.post( "https://api.sawalni.com/v1/language/encode", headers={"Authorization": "Bearer YOUR_API_KEY"}, json={ "model": "sawtone-v4", "input": ["word1", "word2", "word3"], "channel": "composite" } )

Model Details

PropertyValue
Model IDsawtone-v4
Composite Dimension544
Sentence Embeddings768
Max Batch Size128

Pricing

Word encoding is metered by input bytes (UTF-8 encoded size).

MetricRate
Input bytes0.10 credits per 1M bytes

Use Cases

  • Cross-lingual word similarity — Compare words across languages via cosine similarity
  • Phonetic search — Find phonetically similar words using the phonetic channel
  • Script-agnostic clustering — Group words by sound/meaning regardless of script
  • Lexicon building — Build multilingual lexicons using semantic embeddings
  • Transliteration features — Use orthographic embeddings as features for transliteration models