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.2.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.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kronoslabs-1.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 106bcd0df75c86436ebbd0c81ceb91bdc487530b5a3da027cfd8ab71b02e593b
MD5 963ddb8ae49a14b2e04991f34824b7f7
BLAKE2b-256 f0f4cec7dc59a7e92a14adc669827ebd390add4f4258174ecc931f68a168578e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kronoslabs-1.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec6e98f57ab04182ec51cccb5faf5d867b16ac68766d63cb4f285a3bc239e1d4
MD5 3ef5a98f47368a066aaf5e4ae2f30dda
BLAKE2b-256 ccbeecdfe69cf3ea088ea33c354529a2364e67fee03e85a5b42c8954d332af74

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