import Casedev from 'casedev';
const client = new Casedev({ apiKey: 'sk_case_YOUR_API_KEY' });
const result = await client.llm.v1.createEmbedding({
model: 'openai/text-embedding-3-small',
input: 'Plaintiff alleges negligence in post-operative care'
});
console.log(result.data[0].embedding); // [0.016, -0.022, ...]
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [-0.016, 0.022, -0.011, ...]
}
],
"model": "openai/text-embedding-3-small",
"usage": {
"prompt_tokens": 12,
"total_tokens": 12
}
}
Parameters
| Parameter | Type | Required | Description |
|---|
model | string | Yes | Embedding model ID |
input | string or array | Yes | Text(s) to embed |
Embedding models
| Model | Dimensions | Best for | $/1K tokens |
|---|
openai/text-embedding-3-small | 1536 | General purpose | $0.00002 |
openai/text-embedding-3-large | 3072 | Higher quality | $0.00013 |
voyage/voyage-law-2 | 1024 | Legal documents | $0.00012 |
voyage/voyage-3.5 | 1536 | General purpose | $0.00006 |
For legal documents, use voyage/voyage-law-2. It’s specifically trained on legal text.
Batch embeddings
Embed multiple texts in one request:
const result = await client.llm.v1.createEmbedding({
model: 'openai/text-embedding-3-small',
input: [
'Medical record from January 2024',
'Deposition transcript page 45',
'Expert witness report summary'
]
});
// result.data[0].embedding, result.data[1].embedding, ...
Use cases
Semantic search
// 1. Embed your query
const queryResult = await client.llm.v1.createEmbedding({
model: 'voyage/voyage-law-2',
input: 'negligence in surgical procedure'
});
// 2. Compare to document embeddings (cosine similarity)
// 3. Return most similar documents
Document similarity
// Compare two documents
const result = await client.llm.v1.createEmbedding({
model: 'voyage/voyage-law-2',
input: [
'Plaintiff expert testimony on standard of care',
'Defense expert rebuttal on treatment protocols'
]
});
// Calculate cosine similarity:
// ~1.0 = very similar, ~0.5 = somewhat related, ~0.0 = unrelated
Tip: Use the same model for indexing and querying. Mixing models produces poor results.