Skip to main content

Python client for SeekrAI

Project description

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

client = SeekrFlow(api_key="xxxxx")

Usage – Python Client

Chat Completions

import os
from seekrai import SeekrFlow

client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))

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

client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
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

async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
messages = [
    "What are the top things to do in San Francisco?",
    "What country is Paris in?",
]


async def async_chat_completion(messages):
    async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
    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

client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))

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

client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))

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

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

seekrai-0.5.33.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

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

seekrai-0.5.33-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seekrai-0.5.33.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.2 Darwin/25.0.0

File hashes

Hashes for seekrai-0.5.33.tar.gz
Algorithm Hash digest
SHA256 823150ecc3623886f6c61145b43ed7426fe9ede0e1b671fd38d4470993be70c1
MD5 b67a96c06b48b7bc6f238a41ae24df58
BLAKE2b-256 2221f77baeb5e1caa0c8c4599cd936bc1f8e9ef5d9b426b83f02e640ad6b780f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seekrai-0.5.33-py3-none-any.whl
  • Upload date:
  • Size: 83.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.2 Darwin/25.0.0

File hashes

Hashes for seekrai-0.5.33-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8abc43aff1b05da07d19d65eea66a31b158ee04fdd64fb0c950870715b900e
MD5 be502a2a61d1da2a3fd6f19ad84d61a2
BLAKE2b-256 53ca5a52ffa03d6b023bfaed0331d4e5e4c14bb8d7be13ce93aa4a748ef8c3e0

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