Skip to content

Hosted API client

olaverse.Client calls the Olaverse API, which runs the latest models without a GPU or any downloads. It needs only requests, which pip install olaverse already installs.

from olaverse import Client

client = Client()  # reads OLAVERSE_API_KEY
client.diacritize("se eranko naa si gbo o?", language="yor")
# 'ṣé ẹranko náà sì gbọ́ o?'

Setup

Create a key in the developer console, then either set it in the environment or pass it in:

export OLAVERSE_API_KEY=sk-...
client = Client(api_key="sk-...")

The client also reads OLAVERSE_KEY, the name used in the API docs' examples, and OLAVERSE_URL to point at a different base URL.

Option Default Meaning
timeout 120 Seconds per HTTP request
max_retries 3 Retries for 429, 502, 503, 504 and dropped connections
max_retry_delay 60 Longest single wait, including a server's Retry-After
max_concurrency 4 Batches in flight at once when a list spans several batches

One call per task

Every method takes one input or a list. A list is split into the API's batch sizes, the batches are sent at the same time, and the results come back in input order.

Method Endpoint Models Batch size
diacritize(text) /v1/diacritize diacnet-2.0 (default), diacnet-mini-2.0, diactag-2.0 64
detect_language(text) /v1/language-id lid-neural-608 (default), lid-lite-608 256
generate_questions(passage) /v1/questions/generate mist-qg-1.1 64 (200k chars)
extract(text, template=...) / extract_many(docs, template=...) /v1/extract mist-extract-1.0 16
decide(state, questions=...) / decide_many(states, questions=...) /v1/decide purplemist-mini-2.0 32

Model names work in any case and with or without the olaverse/ prefix. Naming a model the API does not serve (for example diactag-1.0, which runs locally) fails before any request is sent.

Diacritics

client.diacritize(["Toi khong biet", "El nino esta en la casa"], language=["vie", "spa"])
client.diacritize("ذهب الطالب الى المدرسة", language="ara", case_endings=False)
client.diacritize("ogun", model="diacnet-2.0", hints={"ogun": "war"})
client.diacritize(text, model="diactag-2.0", min_confidence=0.9)

Language identification

r = client.detect_language("Bawo ni?")
r.language, r.label, r.name, r.confidence  # 'yor', 'yor_Latn', 'Yoruba', 0.98
r.top                                      # runner-up languages

client.detect_language(texts, model="lid-lite-608", mode="coverage", top_k=5)

Question generation

q = client.generate_questions(passage, n=3, question_language="en")
list(q)                 # ['...?', '...?', '...?']
q.language, q.warnings  # detected passage language, any warnings

Extraction

r = client.extract(
    sms_text,
    template={"amount": "number", "sender": "string", "date": "date"},
    instructions="Dates are day/month/year",
)
if r.ok:
    r["amount"], r.confidence["amount"]

client.extract(template={"total": "number"}, image="receipt.jpg")  # path, bytes or base64

If the model's output was not valid JSON, the API answers with data=None and does not bill for it. r.ok is then False and r.error says why.

Decisions

d = client.decide(
    ticket_text,
    questions={
        "team": {"type": "choice", "options": {"billing": "Payments and refunds", "tech": "Bugs"}},
        "refund": {"type": "noul"},
    },
)
d["team"]["choice"], d["refund"]["noul"]

Errors

Every failure raises a subclass of olaverse.APIError, with .status, .message and .detail.

Exception Status Retried
BadRequest 400 no
AuthenticationError 401, 403 no
InsufficientCredit 402 no
RequestTooLarge 413 no
ValidationError 422 no
RateLimited 429 yes
ServerError 5xx 502, 503 and 504
APIConnectionError — connection failures only; a read timeout is not resent, because the request may already have run

In a batched call, items succeed or fail on their own. If any item fails, BatchError is raised. Its .results holds every result in input order, with an APIError in place of each failed item, and .errors lists (index, error) pairs, so you can retry just those items.

from olaverse.api import BatchError

try:
    results = client.extract_many(docs, template=template)
except BatchError as e:
    results = e.results
    retry = [docs[i] for i, _ in e.errors]

Free endpoints

client.models() lists the models the API serves right now, with pricing. client.health() checks the service. Neither needs a key.