Skip to main content

The Seekr Python Library is the official Python client for SeekrFlow's API platform, providing a convenient way for interacting with the REST APIs and enables easy integrations with Python 3.9+ applications with easy to use synchronous and asynchronous clients.

Installation

To install Seekr Python Library from PyPi, simply run:

pip install --upgrade seekrai

Setting up API Key

🚧 You will need to create an account with Seekr.com to obtain a SeekrFlow API Key.

Setting environment variable

export SEEKR_API_KEY=xxxxx

Using the client

from seekrai import SeekrFlow

with SeekrFlow(api_key="xxxxx") as client:
    response = client.models.list()
    print(response.data)

Client lifecycle and connection reuse

SeekrFlow and AsyncSeekrFlow reuse an internal HTTP client per SDK client instance.

Recommended usage:

  1. Create one SDK client per app scope or per cached user scope (not per request).
  2. Reuse that SDK client for all calls in that scope.
  3. Close the SDK client on shutdown/eviction (close() or aclose()), or use context managers (with / async with).

If you already manage your own httpx.Client / httpx.AsyncClient or need custom pool settings, etc, inject it via http_client= or async_http_client= and keep lifecycle ownership in your app.

import httpx
from seekrai import SeekrFlow

shared_http_client = httpx.Client(
    http2=True,
    limits=httpx.Limits(max_connections=200, max_keepalive_connections=100),
)
try:
    client = SeekrFlow(api_key="xxxxx", http_client=shared_http_client)
    # ... reuse client across calls
finally:
    shared_http_client.close()

If your app caches one SDK client per user, use a shared HTTP transport for all cached SDK instances. This avoids one connection pool per user and keeps socket/FD usage bounded by one global pool.

import httpx
from cachetools import TTLCache
from seekrai import SeekrFlow

shared_http_client = httpx.Client(
    http2=True,
    limits=httpx.Limits(max_connections=300, max_keepalive_connections=100),
)
sdk_cache: TTLCache[str, SeekrFlow] = TTLCache(maxsize=5000, ttl=900)


def get_user_client(user_id: str, api_key: str) -> SeekrFlow:
    client = sdk_cache.get(user_id)
    if client is None:
        client = SeekrFlow(api_key=api_key, http_client=shared_http_client)
        sdk_cache[user_id] = client
    return client


def shutdown() -> None:
    # SDK clients do not own injected transport.
    shared_http_client.close()

Apply the same pattern for async apps with one shared httpx.AsyncClient injected into cached AsyncSeekrFlow instances, and close it once during app shutdown.

RBAC Team Routing

Every API key currently resolves to a personal team. We do not currently have application-level or shared team-level API keys.

The SDK can send the RBAC context header x-team-id when provided. This header does not grant access by itself.

Authorization is enforced server-side using the authenticated identity (API key/JWT). A request is only allowed if that identity has access to the requested team. If no team context is provided, the backend defaults to the personal team resolved from authentication.

You can set team context in either of these ways:

  1. Set SEEKR_TEAM_ID and let the SDK populate x-team-id automatically.
  2. Pass supplied_headers={"x-team-id": "..."} explicitly.

If both are provided, supplied_headers["x-team-id"] takes precedence.

import os
from seekrai import SeekrFlow

with SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as client:
    response = client.models.list()
    print(response.data)
import os
import asyncio
from seekrai import AsyncSeekrFlow

async def run():
    async with AsyncSeekrFlow(
        api_key=os.environ.get("SEEKR_API_KEY"),
        supplied_headers={"x-team-id": os.environ.get("SEEKR_TEAM_ID")},
    ) as async_client:
        response = await async_client.models.list()
        print(response.data)

asyncio.run(run())

Usage – Python Client

Chat Completions

import os
from seekrai import SeekrFlow

with SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as client:
    response = client.chat.completions.create(
        model="meta-llama/Llama-3.1-8B-Instruct",
        messages=[{"role": "user", "content": "tell me about new york"}],
    )

print(response.choices[0].message.content)

Streaming

import os
from seekrai import SeekrFlow

with SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as client:
    stream = client.chat.completions.create(
        model="meta-llama/Llama-3.1-8B-Instruct",
        messages=[{"role": "user", "content": "tell me about new york"}],
        stream=True,
    )

    for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Async usage

import os, asyncio
from seekrai import AsyncSeekrFlow

messages = [
    "What are the top things to do in San Francisco?",
    "What country is Paris in?",
]


async def async_chat_completion(messages):
    async with AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as async_client:
        tasks = [
            async_client.chat.completions.create(
                model="meta-llama/Llama-3.1-8B-Instruct",
                messages=[{"role": "user", "content": message}],
            )
            for message in messages
        ]
        responses = await asyncio.gather(*tasks)

        for response in responses:
            print(response.choices[0].message.content)


asyncio.run(async_chat_completion(messages))

Files

The files API is used for fine-tuning and allows developers to upload data to fine-tune on. It also has several methods to list all files, retrieve files, and delete files

import os
from seekrai import SeekrFlow

with SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as client:
    client.files.upload(file="somedata.parquet")  # uploads a file
    client.files.list()  # lists all uploaded files
    client.files.delete(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815")  # deletes a file

Fine-tunes

The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrieve statuses and get checkpoints.

import os
from seekrai import SeekrFlow

with SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY")) as client:
    client.fine_tuning.create(
        training_file='file-d0d318cb-b7d9-493a-bd70-1cfe089d3815',
        model='meta-llama/Llama-3.1-8B-Instruct',
        n_epochs=3,
        n_checkpoints=1,
        batch_size=4,
        learning_rate=1e-5,
        suffix='my-demo-finetune',
    )
    client.fine_tuning.list()  # lists all fine-tuned jobs
    client.fine_tuning.retrieve(id="ft-c66a5c18-1d6d-43c9-94bd-32d756425b4b")  # retrieves information on finetune event

Download files

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

Source Distribution

seekrai-0.34.4.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

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

seekrai-0.34.4-py3-none-any.whl (107.7 kB view details)

Uploaded Python 3

File details

Details for the file seekrai-0.34.4.tar.gz.

File metadata

  • Download URL: seekrai-0.34.4.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for seekrai-0.34.4.tar.gz
Algorithm Hash digest
SHA256 450cc9fc00794c98cb22e123a5ffc00734a11058c3cbf1b1eade01f5a0de5cd4
MD5 14fca0b4b08a7a55769ff4fb2b6ec6e2
BLAKE2b-256 ea2fe2413d738e6ad5ce07d47e47239a6d139db7f54dc14b165cc03bea6de3bd

See more details on using hashes here.

File details

Details for the file seekrai-0.34.4-py3-none-any.whl.

File metadata

  • Download URL: seekrai-0.34.4-py3-none-any.whl
  • Upload date:
  • Size: 107.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for seekrai-0.34.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c02f3cbef3c77d5dfb671fce41f4ad7f27a9b7eba45193b5726b0f0a5ed3f930
MD5 e962d8d75add0887e7e9fc331a1c3c0f
BLAKE2b-256 9d3ab30dc4f2f1f5f24e3b9668702b2b40c59b8eeda58f6bf69052299b063a0f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

This release

0.34.4 This release

2 files

0.34.3

2 files

0.34.2

2 files

0.34.1

2 files

0.34.0

2 files

0.33.1

2 files

0.33.0

2 files

0.32.0

2 files

0.31.1

2 files

0.31.0

2 files

0.30.0

2 files

0.29.1

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.0

2 files

0.22.2

2 files

0.22.1

2 files

0.22.0

2 files

0.21.0

2 files

0.20.0

2 files

0.19.0

2 files

0.18.0

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.6

2 files

0.14.4

2 files

0.14.3

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.12.2

2 files

0.12.1

2 files

0.10.1

2 files

0.9.0

2 files

0.7.11

2 files

0.7.0

2 files

0.6.0

2 files

0.5.33

2 files

0.5.29

2 files

0.5.28

2 files

0.5.26

2 files

0.5.25

2 files

0.5.24

2 files

0.5.17

2 files

0.5.16

2 files

0.5.15

2 files

0.5.14

2 files

0.5.13

2 files

0.5.12

2 files

0.5.11

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.2

2 files

0.4.1

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page