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
response = client.chat.completions.create(
    prompt="Hello, how are you?",
    temperature=0.7,
    is_stream=False
)

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

# Streaming chat completion
stream = client.chat.completions.create(
    prompt="Tell me a story",
    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 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
    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
  • 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.0.0.tar.gz (5.8 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.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kronoslabs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5d7b305512ea33b1b69192fcc324ef96d7e45970c08770a1d0c4fb45342495be
MD5 12655f9e46f5eb746ef489f6dde89d25
BLAKE2b-256 7f395f049a1717605b81bb7add047bbb2f303d23fe3b64f378f5284eeac25a8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kronoslabs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 803c0f8f4490c936b5ebbd658c2fb657029ab50c5458eb5de14bc6fac4dfb857
MD5 778ec3a5c140a61931c7d1e21fb782f2
BLAKE2b-256 d015977ba45b907fa207ee376bc25bf0d30d04e9276c217bdecd87c111ab6164

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