PerslyPersly API
API Reference

Embeddings

Generate vector embeddings optimized for medical text.

POST https://api.persly.ai/v1/embeddings

Creates embedding vectors for the given input text. The embeddings are 768-dimensional vectors optimized for medical text similarity and retrieval tasks.

Request Body

ParameterTypeRequiredDefaultDescription
modelstringYesMust be persly-embed-v1
inputstring | string[]YesText to embed. Single string or array of up to 100 strings.
encoding_formatstringNo"float"Output format. Only "float" is supported.

Response Body

FieldTypeDescription
idstringUnique request ID in emb_{hex} format
objectstringAlways "list"
createdintegerUnix timestamp
modelstring"persly-embed-v1"
dataarrayArray of embedding objects
data[].objectstringAlways "embedding"
data[].indexintegerIndex corresponding to the input array position
data[].embeddingnumber[]768-dimensional embedding vector
usageobjectToken usage information
usage.prompt_tokensintegerNumber of input tokens processed
usage.total_tokensintegerTotal tokens (same as prompt_tokens for embeddings)

Examples

Single Text

curl https://api.persly.ai/v1/embeddings \
  -H "Authorization: Bearer $PERSLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "persly-embed-v1",
    "input": "Symptoms of acute myocardial infarction include chest pain, dyspnea, and diaphoresis."
  }'
import requests

response = requests.post(
    "https://api.persly.ai/v1/embeddings",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "persly-embed-v1",
        "input": "Symptoms of acute myocardial infarction include chest pain, dyspnea, and diaphoresis.",
    },
)

data = response.json()
embedding = data["data"][0]["embedding"]
print(f"Dimensions: {len(embedding)}")  # 768
print(f"Tokens used: {data['usage']['prompt_tokens']}")
const response = await fetch("https://api.persly.ai/v1/embeddings", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "persly-embed-v1",
    input:
      "Symptoms of acute myocardial infarction include chest pain, dyspnea, and diaphoresis.",
  }),
});

const data = await response.json();
const embedding = data.data[0].embedding;
console.log(`Dimensions: ${embedding.length}`); // 768
console.log(`Tokens used: ${data.usage.prompt_tokens}`);

Response

{
  "id": "emb_a1b2c3d4e5f6a1b2c3d4e5f6",
  "object": "list",
  "created": 1709000000,
  "model": "persly-embed-v1",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023064255, -0.009327292, 0.015797347, ...]
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "total_tokens": 18
  }
}

Batch Request

Embed multiple texts in a single request (up to 100 items):

curl https://api.persly.ai/v1/embeddings \
  -H "Authorization: Bearer $PERSLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "persly-embed-v1",
    "input": [
      "Patient presents with chest pain radiating to left arm.",
      "Blood glucose level of 250 mg/dL indicates hyperglycemia.",
      "MRI shows herniated disc at L4-L5 level."
    ]
  }'
Batch response
{
  "id": "emb_...",
  "object": "list",
  "created": 1709000000,
  "model": "persly-embed-v1",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.002, -0.009, ...]},
    {"object": "embedding", "index": 1, "embedding": [0.011, 0.003, ...]},
    {"object": "embedding", "index": 2, "embedding": [-0.005, 0.012, ...]}
  ],
  "usage": {
    "prompt_tokens": 42,
    "total_tokens": 42
  }
}

Errors

StatusCodeCause
400model_not_foundInvalid model (must be persly-embed-v1)
400invalid_requestInvalid encoding_format or empty input strings
400batch_size_exceededBatch contains more than 100 items
401authentication_errorInvalid API key
429quota_exceededFree credits exhausted
429spending_limit_exceededMonthly spending limit reached

On this page