Skip to main content

Official Python client for Kronos Labs API

Project description

Kronos Labs Python Client

Official Python client for the Kronos Labs API.

Installation

pip install kronoslabs

Quick Start

from kronoslabs import KronosLabs

# Initialize the client
client = KronosLabs(api_key="your-api-key-here")

# Non-streaming chat completion with hyperion model
response = client.chat.completions.create(
    prompt="Hello, how are you?",
    model="hyperion",  # or "hermes"
    temperature=0.7,
    is_stream=False
)

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

# Streaming chat completion with hermes model
stream = client.chat.completions.create(
    prompt="Tell me a story",
    model="hermes",
    temperature=0.7,
    is_stream=True
)

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

Features

  • Simple and intuitive API similar to OpenAI's ChatGPT client
  • Support for multiple models: hyperion and hermes
  • Support for both streaming and non-streaming responses
  • Automatic handling of API authentication
  • Comprehensive error handling
  • Type hints for better IDE support
  • Tool calling (coming soon)

API Reference

Initialize Client

client = KronosLabs(api_key="your-api-key")

Chat Completions

response = client.chat.completions.create(
    messages=[],  # Optional: list of message dicts
    prompt="Your prompt here",  # Required: the prompt text
    model="hermes",  # Optional: "hyperion" or "hermes" (default: "hyperion")
    temperature=0.7,  # Optional: controls randomness (0.0-2.0)
    is_stream=False,  # Optional: enable streaming
    tool=False  # Optional: enable tool usage (Work in Progress - not yet functional)
)

Parameters

  • messages (list, optional): List of message dictionaries with 'role' and 'content' keys
  • prompt (str, required): The prompt text to send to the model
  • model (str, optional): Model to use - either "hyperion" or "hermes". Default: "hyperion"
  • temperature (float, optional): Controls randomness in the response (0.0-2.0). Default: 0.7
  • is_stream (bool, optional): Enable streaming responses. Default: False
  • tool (bool, optional): Work in Progress - Tool calling functionality is currently under development and not yet available. Default: False

Response Format

Non-streaming response:

{
    "id": "chatcmpl_...",
    "object": "chat.completion",
    "created": 1234567890,
    "model": "hyperion-1.5b-chat",
    "choices": [{
        "index": 0,
        "message": {
            "role": "assistant",
            "content": "Response text"
        },
        "finish_reason": "stop"
    }],
    "usage": {
        "prompt_tokens": 10,
        "completion_tokens": 20,
        "total_tokens": 30
    }
}

Streaming response (yields chunks):

{
    "id": "chatcmpl_...",
    "object": "chat.completion.chunk",
    "created": 1234567890,
    "model": "hyperion-1.5b-chat",
    "choices": [{
        "index": 0,
        "delta": {
            "content": "token"
        },
        "finish_reason": null
    }]
}

Error Handling

from kronoslabs import KronosLabs, APIError, AuthenticationError

client = KronosLabs(api_key="your-api-key")

try:
    response = client.chat.completions.create(prompt="Hello")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except APIError as e:
    print(f"API error: {e.message}, Status: {e.status_code}")

License

MIT License

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

kronoslabs-1.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

kronoslabs-1.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file kronoslabs-1.1.1.tar.gz.

File metadata

  • Download URL: kronoslabs-1.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for kronoslabs-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d417e06d3e135d073c01629649eb128747a08bd7e7d20efe2bc2195a938e45da
MD5 2bb26f1e26b6fb527f0e91a11fcd84e5
BLAKE2b-256 cf843f80c76ad16faf7efa8297ee5f511e52d269cfcf59eecb2f59e2d2317f47

See more details on using hashes here.

File details

Details for the file kronoslabs-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: kronoslabs-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for kronoslabs-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21a684cb2e954bd756fa75563345fc5e77a866313881496f4e55a0739699cf3e
MD5 f5338ad500bda6f1fc1a4c2df092d76d
BLAKE2b-256 a13ef469e4f734e8ab5af50b093d5331e3332e014345228bea45afeedf667fd6

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