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

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="hyperion",  # Optional: "hyperion" or "hermes" (default: "hyperion")
    temperature=0.7,  # Optional: controls randomness (0.0-2.0)
    is_stream=False,  # Optional: enable streaming
    tool=True  # Optional: enable tool usage
)

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): Enable tool usage. Default: True

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.0.tar.gz (6.5 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.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kronoslabs-1.1.0.tar.gz
  • Upload date:
  • Size: 6.5 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.0.tar.gz
Algorithm Hash digest
SHA256 6cf82f6dc0e12af36716cba25d8ee3121ea0b21c7edc9290fcb956d5a4c8cfb3
MD5 2dbea6b5763a21c965e7de05f1e0174e
BLAKE2b-256 7360736154bb7a0f2beb394f1fc4494f98d4ba1e696c528b31704c4eca7290ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kronoslabs-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24b6796f6ee01dfc642693fe8c62d43ea32566dd5e1fa4c7076c0414b76f7896
MD5 2370c6fa5dd5e225a2c1763192ffd1b1
BLAKE2b-256 840b7deaef4afa5e387f301794a025ec59be8b430210b160475d570c78aa260b

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