Skip to main content

Python SDK for the PolyEmbed embeddings API

Project description

polyembed

Python SDK for the PolyEmbed embeddings API by a23one.

Install

pip install polyembed

Usage

from polyembed import PolyEmbed

client = PolyEmbed(api_key="pe_<team>_<key>")

# Single embedding
embedding = client.embed("hello world", input_type="document")
# [0.0229, 0.0319, ...]  (1024 floats)

# Limit tokens for faster responses (512–4096, capped by team's plan)
embedding = client.embed("short query", input_type="query", max_tokens=512)

# Batch (1-100 texts)
embeddings = client.embed_batch(
    ["text one", "text two"],
    input_type="document",
    max_tokens=1024,  # optional — cap tokens per text
)

# Shielded (encrypted, non-reversible)
embedding = client.embed(
    "classified report",
    input_type="document",
    shielded=True,
)

# Full response metadata
from polyembed import EmbedResponse

response = client.embed("hello", input_type="query", raw=True)
response.embedding   # list[float]
response.model       # "base"
response.shielded    # False
response.dimensions  # 1024
response.max_tokens  # 4096 (effective limit applied)

Configuration

client = PolyEmbed(
    api_key="pe_...",
    base_url="https://polyembed.com",  # default
    timeout=30,                         # seconds
    max_retries=3,                      # retries on 429/5xx
)

Error handling

from polyembed import AuthenticationError, ValidationError, RateLimitError, ServerError

try:
    embedding = client.embed("hello", input_type="document")
except AuthenticationError:
    # 401 — invalid or expired API key
except ValidationError:
    # 400 — invalid parameters
except RateLimitError:
    # 429 — rate limit exceeded (retried automatically)
except ServerError:
    # 500/502/503/504 — server error (retried automatically)

Context manager

with PolyEmbed(api_key="pe_...") as client:
    embedding = client.embed("hello", input_type="document")

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

polyembed-0.0.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

polyembed-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file polyembed-0.0.2.tar.gz.

File metadata

  • Download URL: polyembed-0.0.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for polyembed-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7a560f661b6c81d50c6602193599ef23f0891a5e913eae989bdfb57ee43367bf
MD5 3a9534f43a7d326b55f39d8c7ea3e377
BLAKE2b-256 fc5ebc88735e233ea2abf1c747e582d1ac80392b4b0c654d55fb1b4ade80cf99

See more details on using hashes here.

File details

Details for the file polyembed-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: polyembed-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for polyembed-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1aab7f12ada6fbbaeb6852749149c6b2420a80fb6c85902911a76f71ec057d09
MD5 df80c7b77e855e22364835f492373dd2
BLAKE2b-256 5c5465d2383ac792c382cedfe87f2cfd9045e06caa9502fecdb214a82bab24ca

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