Skip to main content

Python client for the Olive distributed AI compute platform

Project description

Olive Python SDK

Distributed AI compute — embeddings and inference — with one import.

pip install olive-compute

Quickstart

from olive import OliveClient

client = OliveClient(api_key="olv_...")

# Embed text — uses the default embeddings model
vectors = client.embeddings(["hello world", "olive compute"])
print(vectors[0][:4])  # [0.0521, -0.1234, ...]

# Run inference — uses the default chat model
reply = client.inference("What is a neural network?", max_tokens=128)
print(reply)

Choosing a model

Olive supports a catalog of curated open-source models. Browse them at olivecompute.com/models or programmatically:

# List all available chat models
for m in client.list_models(modality="chat"):
    print(m["id"], "—", m["pricing"]["input_per_1m_tokens_usd"], "/1M tokens")

# Get one model's full record
m = client.get_model("meta/llama-3.2-3b-instruct")
print(m["description"])

Pass model= to any inference call to pin a specific model:

reply = client.inference(
    "Write a Python function to reverse a list.",
    model="meta/llama-3.2-3b-instruct",
)

vectors = client.embeddings(
    ["semantic search query"],
    model="baai/bge-small-en-v1.5",
)

If model= is omitted, Olive picks the default (featured) model for the workload.

Authentication

Get an API key from provider.olivecompute.com → Settings → API Keys.

# API key (recommended)
client = OliveClient(api_key="olv_...")

# Email + password (issues a short-lived token automatically)
client = OliveClient(email="you@example.com", password="...")

Compute tiers

Tier CPU RAM Use case
"light" 1 core 2 GB Embeddings, small inputs
"medium" 2 cores 4 GB Standard inference (default)
"heavy" 4 cores 8 GB Long context, large batches

Async jobs

For long-running workloads, submit and poll separately:

import json

job = client.submit_job(
    workload_type="inference",
    input_data=json.dumps({"prompt": "Write a haiku", "max_tokens": 64}),
    model="meta/llama-3.2-3b-instruct",   # optional — default chat model otherwise
    compute="medium",
)
print(job.id)       # e3b2a1c0-...
print(job.status)   # "running"

# No explicit timeout: waits long enough to cover one automatic retry
# if the assigned device doesn't respond in time.
result = job.wait()
print(json.loads(result["output_data"])["text"])

Error handling

from olive import OliveClient, AuthError, JobError

try:
    client = OliveClient(api_key="olv_bad_key")
    vectors = client.embeddings(["test"])
except AuthError:
    print("Check your API key")
except JobError as e:
    print(f"Job failed: {e}")

Context manager

with OliveClient(api_key="olv_...") as client:
    vectors = client.embeddings(["hello"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

olive_compute-0.1.2.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

olive_compute-0.1.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file olive_compute-0.1.2.tar.gz.

File metadata

  • Download URL: olive_compute-0.1.2.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for olive_compute-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ab8ef7cccb8eda354096706ec3fceb4989fe780f34693012b287461ff6576cc0
MD5 a8ff9fcf5b571da3aa911029382ccc4e
BLAKE2b-256 43dc56988741d6606c68e077d9a84b07e9ff9efc518b3711de8461f6f0d5acad

See more details on using hashes here.

File details

Details for the file olive_compute-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: olive_compute-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for olive_compute-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2331664e3aa0ea140b61874e01535d5ff698f8c15daa507e2d9536507cf49f06
MD5 ef6481206d733b95933f504c8f28cadc
BLAKE2b-256 fa3993b8b606246e85bd6494f3d2085d365bd5be478f0906dd169b854b909fa0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page